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.

内容类别 None.
准许内容 One <head> element, followed by one <body> 元素。
Tag omission The start tag may be omitted if the first thing inside the <html> element is not a comment.
The end tag may be omitted if the <html> element is not immediately followed by a comment.
Permitted parents None. This is the root element of a document.
Implicit ARIA role 无对应角色
Permitted ARIA roles No role permitted
DOM 接口 HTMLHtmlElement

属性

此元素包括 全局属性 .

manifest
Specifies the URI of a resource manifest indicating resources that should be cached locally. See Using the application cache 了解细节。
version
Specifies the version of the HTML Document Type Definition that governs the current document. This attribute is not needed, because it is redundant with the version information in the document type declaration.
xmlns
Specifies the XML Namespace of the document. Default value is "http://www.w3.org/1999/xhtml" . This is required in documents parsed with XML parsers , and optional in text/html documents.

范例

<!DOCTYPE html>
<html lang="en">
  <head>...</head>
  <body>...</body>
</html>

可访问性关注

Providing a lang attribute with a valid IETF identifying language tag <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.

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.

规范

规范 状态 注释
HTML 实时标准
The definition of '<html>' in that specification.
实时标准
HTML5
The definition of '<html>' in that specification.
推荐 添加支持 manifest attribute (deprecated later).
Obsoleted the version 属性
HTML 4.01 Specification
The definition of '<html>' in that specification.
推荐 Deprecated the version 属性

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
html Chrome 完整支持 Yes Edge 完整支持 12 Firefox 完整支持 Yes IE 完整支持 Yes Opera 完整支持 Yes Safari 完整支持 Yes WebView Android 完整支持 Yes Chrome Android 完整支持 Yes Firefox Android 完整支持 Yes Opera Android 完整支持 Yes Safari iOS 完整支持 Yes Samsung Internet Android 完整支持 Yes
manifest 弃用 Chrome 完整支持 4 Edge 完整支持 12 Firefox 完整支持 3.5
完整支持 3.5
部分支持 3 注意事项
注意事项 Versions of Firefox prior to 3.5 ignore the NETWORK and FALLBACK sections of the cache manifest file.
IE 完整支持 10 Opera 完整支持 10.6 Safari 完整支持 4 WebView Android 完整支持 4 Chrome Android 完整支持 18 Firefox Android 完整支持 4 Opera Android 完整支持 11 Safari iOS 完整支持 3.2 Samsung Internet Android 完整支持 1.0
version 弃用 Chrome 完整支持 Yes Edge 完整支持 12 Firefox 完整支持 Yes IE 完整支持 Yes Opera 完整支持 Yes Safari 完整支持 Yes WebView Android 完整支持 Yes Chrome Android 完整支持 Yes Firefox Android 完整支持 Yes Opera Android 完整支持 Yes Safari iOS 完整支持 Yes Samsung Internet Android 完整支持 Yes
xmlns Chrome 完整支持 Yes Edge 完整支持 12 Firefox 完整支持 Yes IE 完整支持 Yes Opera 完整支持 Yes Safari 完整支持 Yes WebView Android 完整支持 Yes Chrome Android 完整支持 Yes Firefox Android 完整支持 Yes Opera Android 完整支持 Yes Safari iOS 完整支持 Yes Samsung Internet Android 完整支持 Yes

图例

完整支持

完整支持

弃用。不要用于新网站。

弃用。不要用于新网站。

见实现注意事项。

见实现注意事项。

另请参阅

元数据

  • 最后修改: