如何评论HTML源代码中的HTML标签属性? [英] How to comment HTML tag attribute in HTML source code?
问题描述
< a / * title =需要注释掉* />链接< / a>
W3C文档建议不能这样做:
请注意,注释是标记。
这基本上意味着<! - ...>
comment标签与其他标签一样,所以< a<! - title =需要注释掉 - >>一个连结< / a>
与< a< span>< / span>>连结< / a>
。
对于快速入侵,我相信一个常用选项是重命名该属性。当您获取无效的HTML时,您可以暂时删除该属性:
< a xtitle =需要注释掉>链接< / a>
如果您碰巧使用的是服务器端语言,您也可以使用它自己的注释语法。例如,在PHP中,您可以这样做:
< a<?php / * title =需要评论out* /?>>链接< / a>
...它生成这个HTML:
< a>链接< / a>
...在ASP.NET中,您可以使用<% - - Comment here here - %>
,而MVC Razor的语法是 @ *评论在这里* @
For example:
<a /*title="need to be comment out"*/>a link</a>
The W3C documentation suggests it cannot be done:
Note that comments are markup.
This basically means that a <!-- ...>
comment tag is just like any other tag, so <a <!--title="need to be comment out"-->>a link</a>
is as wrong as <a <span></span>>a link</a>
.
For quick hacking I believe a common option is to rename that attribute. While you obtain invalid HTML you can temporarily remove the attribute:
<a xtitle="need to be comment out">a link</a>
If you happen to be using a server side language, you can also use its own comment syntax. For instance, in PHP you can do this:
<a <?php/*title="need to be comment out"*/?>>a link</a>
... which generates this HTML:
<a >a link</a>
... and in ASP.NET you can use <%-- Comment goes here --%>
while the MVC Razor syntax is @* Comment goes here *@
这篇关于如何评论HTML源代码中的HTML标签属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!