Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
HTML5中的正确关闭或自动关闭标记_Html_Doctype - Fatal编程技术网

HTML5中的正确关闭或自动关闭标记

HTML5中的正确关闭或自动关闭标记,html,doctype,Html,Doctype,我有一个关于关闭自动关闭的HTML标记的问题 哪个更合适 1. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 2. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 3. <meta http-equiv="Content-Type" content="text/html; charset=

我有一个关于关闭自动关闭的HTML标记的问题

哪个更合适

1. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
2. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
1。
2.
3.
此外,如果任何人对此
标签有一个很好的选择,例如:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />
OR
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
文章帮了我一些什么


我使用
作为我的文档类型。

这完全取决于您的文档类型:为了符合XHTML标准,需要使用自动关闭标签。HTML4和HTML5不需要自动关闭标签。

我认为这在某种程度上是个人偏好,因为它都返回相同的结果[在HTML4/5中]。然而,我最常看到的是#3,这正是我已经习惯的方式

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<img src="http://images.wisegeek.com/young-calico-cat.jpg" alt="Smiley face" height="42" />

HTML5
中,严格来说没有必要关闭某些HTML标记。。。(但也有人这样做了)

表格:

8.1.2.1开始标签


6) 然后,如果元素是一个,或者如果元素是一个,则可能有一个“/”(U+002F)字符。此字符对没有影响,但在其上将开始标记标记为自动关闭


我使用
,所以我不需要?这意味着你使用的是HTML5,因此你不需要自动关闭标签。HTML5-来自W3C:Void元素:区域、基、br、col、嵌入、hr、img、输入、键根、链接、元、参数、源、跟踪、wbr“Void元素只有一个开始标签;不能为Void元素指定结束标签。”W3C HTML5标记验证器可能会因为这个而发疯。