HTML5 html 标签和 DOCTYPE

标签 html xhtml doctype

根据我的阅读,开始 HTML5 页面的正确方法是:

<!DOCTYPE html>
<html>

这些行中没有更多内容。这是真的? (我问是因为 Visual Studio 不止于此。)

(另外,我想知道 HTML5 是否真的是当前标准,或者我应该使用 XHTML5 还是其他版本。)

最佳答案

根据HTML living standardthe W3C spec , 文档类型是必需的前导码,但出于遗留原因需要。我引用:

  1. A string that is an ASCII case-insensitive match for the string "<!DOCTYPE".
  2. One or more space characters.
  3. A string that is an ASCII case-insensitive match for the string "html".
  4. Optionally, a DOCTYPE legacy string or an obsolete permitted DOCTYPE string (defined below).
  5. Zero or more space characters.
  6. A U+003E GREATER-THAN SIGN character (>).

In other words, <!DOCTYPE html>, case-insensitively.

<html></html>对于有效文件

(Also, I'm wondering if HTML5 is really the current standard or should I be using XHTML5 or some other version.)

恕我直言,这不是当前标准,因为它尚未完成。但是this article很好地解释了现在使用它的 10 个理由。

关于HTML5 html 标签和 DOCTYPE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13630299/

相关文章:

html - DOCTYPE 的意义何在?

html - 为什么某些 DOCTYPE 声明会导致 100% 高度的表格和 div 停止工作?

javascript - 仅使用 CSS 单击时更改不同按钮的背景和字体颜色。我试过 :focus but only works on Chrome

html - 如何在 window phone 8 上禁用缩放

html - 为什么我的 CSS 样式表不起作用?

javascript - 使用 javascript 使用 if 语句隐藏 div

html - XPath 主要用于Html 或XML 或XHTML?

javascript - 使用 PHP 或 JavaScript 更新用户的链接

jsf - 如何使用 JSF 2.0 Facelets 在 XHTML 中包含另一个 XHTML?

html - &lt;!DOCTYPE html> 防止相对 css 高度