why we use lt;htmlgt; tag although my website runs perfect without lt;htmlgt; tag(为什么我们使用 lt;htmlgt;标记虽然我的网站在没有 lt;htmlgt; 的情况下运行完美标签)
问题描述
我需要从网页的开头知道 <html>
标签的用途,尽管网站在没有这些 <html>
的情况下运行完美</html>
标签.
I need to know what is the use of <html>
tag from the beginning of the webpage although website runs perfectly without these <html>
</html>
tags.
我知道 doctype 是必需的,但为什么需要这个 <html>
标签.
I knew that doctype is required but why this <html>
tag is required.
推荐答案
<html>
标签不是必需的.
来自 DTD:
<!ELEMENT HTML O O (%html.content;) -- document root element -->
两个O
表示开始和结束标记(分别)是可选的.
The two O
s indicate that the start and end tags (respectively) are optional.
另一方面,元素是必需的(但语言的设计是为了让浏览器可以暗示它).
The element, on the other hand, is required (but the language is designed so that browsers can imply it).
由于 DOM 由一棵节点树组成,因此您必须有一个节点(根元素)才能挂起其他所有内容,这就是 html 元素.
Since a DOM consists of a tree of nodes, you have to have one node (the root element) for everything else to hang from, and that is the html element.
这也是一个非常有用的地方,可以粘贴将应用于整个文档的 lang
属性.
It is also a really useful place to stick a lang
attribute that will apply to the entire document.
这篇关于为什么我们使用 <html>标记虽然我的网站在没有 <html> 的情况下运行完美标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么我们使用 <html>标记虽然我的网站在没有 <html> 的情况下运行完美标签


基础教程推荐
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01