根据我的阅读,开始 HTML5 页面的正确方法是:
<!DOCTYPE html>
<html>
这些行中没有更多内容。这是真的? (我问是因为 Visual Studio 不止于此。)
(另外,我想知道 HTML5 是否真的是当前标准,或者我应该使用 XHTML5 还是其他版本。)
最佳答案
根据HTML living standard和 the W3C spec , 文档类型是必需的前导码,但出于遗留原因需要。我引用:
- A string that is an ASCII case-insensitive match for the string
"<!DOCTYPE"
.- One or more space characters.
- A string that is an ASCII case-insensitive match for the string "html".
- Optionally, a DOCTYPE legacy string or an obsolete permitted DOCTYPE string (defined below).
- Zero or more space characters.
- 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/