gpt4 book ai didi

html - 有必要有 吗?

转载 作者:搜寻专家 更新时间:2023-10-31 08:05:08 24 4
gpt4 key购买 nike

我刚看到这样的网站:

<!doctype html>
<head>
..
</head>
<body>
</body>

没有 <html> ,是标准的吗?

最佳答案

如你所见from the specs , HTML 4 早已允许 html , head , 和 body标签都是可选的。

HTML5 规范(您在样本中观察到的 DOCTYPE)also says :

An html element’s start tag may be omitted if the first thing inside the html element is not a comment. An html element’s end tag may be omitted if the html element is not immediately followed by a comment and the element contains a body element that is either not empty or whose start tag has not been omitted.

所以,如果“它是标准的吗?”你的意思是,“根据标准,这是合法的吗?”,答案是“是的”。

但如果“它是标准的吗?”你的意思是,“它是司空见惯的吗?”,那么答案是:“不,你会发现大多数网络浩瀚的 Internet 海洋中的页面往往包含在 <html> 元素中。

请注意,XHTML 不是这种情况。来自 the specs :

The root element of the document must be html.

关于html - 有必要有 <html> 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4710117/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com