Jaw*_*wad 38 html tags comments
当我试试这个
<option disabled = "disabled" <!-- Used to disable any particular option -->
selected = "selected" <!-- Used to pre-select any particular option -->
label = "string" <!-- Used to provide a short version of the content in the option -->
value = "value"> <!-- The actual value that will be send to the server. If omitted the content between the option opening and closing tags will be send. -->
Option 1
</option>
Run Code Online (Sandbox Code Playgroud)
我试图评论元素的openning标记内的属性和值.但是这不起作用,因为浏览器(在IE9,FF4.01,GG11,AF5和Opera11上测试)将禁用="禁用"之后的所有内容视为注释或内容.
元素的开头标记内是否不允许使用HTMl注释?
HTML不允许您在标记内使用<!--和-->标记注释。但是,有一些针对主要用例的解决方法。
您可以构成一个仅用于对自己进行评论的属性。例如:
<div comment="Name and Id">
...
</div>
Run Code Online (Sandbox Code Playgroud)
主要缺点是在缩小过程中不会删除注释,因此:
View source他们将能够阅读您的评论只需使用您知道的表示临时禁用的前缀来重命名该属性。例如,禁用名为的属性option:
<div option="big">
...
</div>
Run Code Online (Sandbox Code Playgroud)
变成
<div DISABLED-option="big">
...
</div>
Run Code Online (Sandbox Code Playgroud)
显然,如果实际上存在一个名为的有效属性,则不要这样做disabled-option。
如果您使用的类或样式不存在,则不会出现错误消息,因此可以执行以下操作来禁用类或样式:
例如,tall在保留名为的类时禁用名为的类highlighted:
<div class="highlighted tall">
...
</div>
Run Code Online (Sandbox Code Playgroud)
变成
<div class="highlighted DISABLED-tall">
...
</div>
Run Code Online (Sandbox Code Playgroud)
同样,要color在保留样式的同时禁用font-weight样式:
<div style="font-weight:700; color:red;">
...
</div>
Run Code Online (Sandbox Code Playgroud)
变成
<div style="font-weight:700; DISABLED-color:red;">
...
</div>
Run Code Online (Sandbox Code Playgroud)
再次提醒您,这些文件在缩小过程中不会被剥离,因此它们将占用最终用户接收的文件中的空间,并且可以通过进行查看View source。
我已经启动了一个用于构建 HTML 注释的标准,称为“HTMLDoc”,类似于 Javascript 的 JSDoc、Java 的 JavaDoc 等。
你可以在这里阅读它:http : //usehtmldoc.surge.sh。
它允许在标签、属性和值级别进行记录。
对于您的代码,它可能如下所示:
<!--
@tag option
@attribute disabled Used to disable any particular option
@attribute selected Used to pre-select any particular option
@attribute label Used to provide a short version of the content in the option
@attribute value The actual value that will be send to the server. If omitted the content between the option opening and closing tags will be send.
-->
<option disabled = "disabled"
selected = "selected"
label = "string"
value = "value">
Option 1
</option>
Run Code Online (Sandbox Code Playgroud)