【发布时间】:2011-07-27 06:28:39
【问题描述】:
我遇到了这段代码
<script class="example" type="text/javascript">
并且很好奇将其写入代码是否有好处
【问题讨论】:
-
我认为你可能遗漏了一些代码... :)
-
有什么好处?我不明白你在问什么。
-
它的好处是使 HTML 无效,因为在 HTML4、XHTML 和 HTML5 上,
script上不允许使用class。现在没有人关心了。 -
@KenLiu:我想你可以自己找到它们:here is a XHTML dtd, and the defaults
%attrs(which include 'class') are not found on thescriptelement。但是,HTML5是一个移动目标,现在该版本允许使用它。您可以使用validator.w3.org:<script class="foobar"></script>在 HTML4 或 XHTML 中失败,但现在在 HTML5 中是允许的。 -
是的,在 HTML5 中是允许的:dev.w3.org/html5/markup/…dev.w3.org/html5/markup/script.html#script
标签: javascript html css