<br>规范还是<br />规范
<img>规范还是<img /> 规范
没有深入研究 觉得很奇怪,今天看了一篇文档 http://blog.jobbole.com/61514/ 结论如下:
如果doctype 是 <!DOCTYPE html>,也就是声明html5的 则<br> 是规范,因为html5 要求br img 不需要闭合(不要关闭无内容标签)
HTML5 (HTML syntax) is preferred for all HTML documents: <!DOCTYPE html>
.
(It’s recommended to use HTML, as text/html
. Do not use XHTML. XHTML, as application/xhtml+xml
, lacks both browser and infrastructure support and offers less room for optimization than HTML.)
Although fine with HTML, do not close void elements, i.e. write <br>
, not <br />
.
如果是
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
xhtml1.1,则 <br /> <img /> 是规范,因为xhtml 是基于xml的 要求所有标签闭合