开发者

Using the XHTML closing slash (/) on normal tags?

开发者 https://www.devze.com 2022-12-22 06:34 出处:网络
I was just wondering whether it is acceptable to close a common tag, eg. a <span> which requires no data using the XHTML closing slash to reduce markup.

I was just wondering whether it is acceptable to close a common tag, eg. a <span> which requires no data using the XHTML closing slash to reduce markup.

So for example:

<span id='hello'>开发者_JAVA百科</span>

could be written as

<span id='hello' />


No you can't do that, span is not self-closing tag. Here are the self closing tags:

<area />
<base />
<basefont />
<br />
<hr />
<input />
<img />
<link />
<meta />


No. What are all the valid self-closing elements in XHTML (as implemented by the major browsers)?


There are empty or self-closing tags. Span is not one of them.

http://justinsomnia.org/2005/12/there-are-only-10-legal-xhtml-empty-tags/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号