<html>: The HTML Document / Root element
<html>
HTML 元素表示 HTML 文档的根(顶层元素),因此也称为根元素。所有其他元素必须是该元素的后代。
¥The <html>
HTML element represents the root (top-level element) of an HTML document, so it is also referred to as the root element. All other elements must be descendants of this element.
属性
¥Attributes
该元素包括 全局属性。
¥This element includes the global attributes.
示例
无障碍问题
¥Accessibility concerns
虽然 HTML 不要求作者指定 <html>
元素开始和结束标记,但作者这样做很重要,因为这将允许他们为网页指定 lang
。根据 <html>
元素上的 RFC 5646: Tags for Identifying Languages (also known as BCP 47) 为 lang
属性提供有效的语言标记将有助于屏幕阅读技术确定要宣布的正确语言。识别语言标签应描述页面大部分内容所使用的语言。如果没有它,屏幕阅读器通常会默认为操作系统的设置语言,这可能会导致发音错误。
¥While HTML does not require authors to specify <html>
element start and ending tags, it is important for authors to do so as it will allow them to specify the lang
for the webpage. Providing a lang
attribute with a valid language tag according to RFC 5646: Tags for Identifying Languages (also known as BCP 47) on the <html>
element will help screen reading technology determine the proper language to announce. The identifying language tag should describe the language used by the majority of the content of the page. Without it, screen readers will typically default to the operating system's set language, which may cause mispronunciations.
在 <html>
元素上包含有效的 lang
声明还可以确保页面的 <head>
中包含的重要元数据(例如页面的 <title>
)也得到正确声明。
¥Including a valid lang
declaration on the <html>
element also ensures that important metadata contained in the page's <head>
, such as the page's <title>
, are also announced properly.
技术总结
¥Technical summary
内容类别 | 没有任何。 |
---|---|
允许的内容 | 一个 <head> 元素,后跟一个 <body> 元素。 |
标签遗漏 |
如果
<html> 元素中的第一个元素不是注释,则可以省略开始标记。如果 <html> 元素后面没有紧跟注释,则可以省略结束标记。
|
允许的父级 | 没有任何。这是文档的根元素。 |
隐式 ARIA 角色 | document |
允许的 ARIA 角色 | 不允许 role |
DOM 接口 | HTMLHtmlElement |
规范
Specification |
---|
HTML Standard # the-html-element |
浏览器兼容性
BCD tables only load in the browser