<script src="foobar.js"/><!-- self-closing script element -->
只有这样才能识别:
1
<script src="foobar.js">
这是否打破了XHTML支持的概念?
注意:此声明至少对所有IE(6-8测试版2)都是正确的。
XHTML 1规格说明:
3。元素最小化和空元素含量
Given an empty instance of an element whose content model is not EMPTY (for example, an empty title or paragraph) do not use the minimized form (e.g. use
and not
).
xhtml dtd将脚本元素指定为:
1 2
<!-- script statements, which may include CDATA sections --> <!ELEMENT script (#PCDATA)>
On the other hand, HTML does have an excellent tag for including
references to outside resources: the tag, and it can be
self-closing. It's already used to include stylesheets, RSS and Atom
feeds, canonical URIs, and all sorts of other goodies. Why not
JavaScript?