html - 你需要一个开始的 <html> 标签吗?

标签 html twitter-bootstrap initializr

我使用 Initializer快速生成 HTML5 + Boostrap 样板并且很好奇为什么创建的 HTML 文档没有开头 <html>标签?

这是 Initializr 为我生成的顶部部分:

<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    <head>

我已经使用 Initializr 部署了几个网站并且没有遇到问题。您需要空缺吗 <html>标签?

最佳答案

来自HTML 5 Specification :

An html element's start tag can be omitted if the first thing inside the html element is not a comment.
An html element's end tag can be omitted if the html element is not immediately followed by a comment.

所以,是的,标签是可选的。

关于html - 你需要一个开始的 <html> 标签吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23018000/

相关文章:

css - MVC5 在 EditorFor 旁边添加字形图标

javascript - 将 id 传递给 Bootstrap 模式内的 link_to_route

html - 父引导行中的中心 div

php - 将站点 URL 添加到站点标题

javascript - flex 容器无法检测窗口 scrollTop 偏移量

python - 使用 Bottlepy 初始化 - CSS 未加载

html - 是否应该监控页面上加载的 html 元素的数量?

html - 删除固定导航栏的主体填充

html - 是否有必要在 twitter bootstrap 中包含 normalize.css 和 h5bp?