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

2020-02-14 10:27发布

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'></span>

could be written as

<span id='hello' />

标签: html xhtml
3条回答
叼着烟拽天下
2楼-- · 2020-02-14 10:49

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/

查看更多
Melony?
4楼-- · 2020-02-14 11:04

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 />
查看更多
登录 后发表回答