<html>: The HTML Document / Root element - HTML: HyperText Markup Language 编辑

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.

Content categoriesNone.
Permitted contentOne <head> element, followed by one <body> element.
Tag omissionThe 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 parentsNone. This is the root element of a document.
Implicit ARIA roleNo corresponding role
Permitted ARIA rolesNo role permitted
DOM interfaceHTMLHtmlElement

Attributes

This element includes the global attributes.

manifest This is an obsolete API and is no longer guaranteed to work.
Specifies the URI of a resource manifest indicating resources that should be cached locally. See Using the application cache for details.
version This is an obsolete API and is no longer guaranteed to work.
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.

Example

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

Accessibility concerns

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

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.

Specifications

SpecificationStatusComment
HTML Living Standard
The definition of '<html>' in that specification.
Living Standard
HTML5
The definition of '<html>' in that specification.
RecommendationAdded support for the manifest attribute (deprecated later).
Obsoleted the version attribute
HTML 4.01 Specification
The definition of '<html>' in that specification.
RecommendationDeprecated the version attribute

Browser compatibility

BCD tables only load in the browser

See also

  • MathML top-level element: <math>
  • SVG top-level element: <svg>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:55 次

字数:8188

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文