HTML <html> 元素 表示一个HTML文档的根(顶级元素),所以它也被称为根元素。所有其他元素必须是此元素的后代。

内容类别
允许内容 一个 <head> 元素,后跟一个 <body> 元素。
允许的父元素 作为文档的根元素,或是在复合文档中任意允许的子文档片段。
DOM 接口 HTMLHtmlElement

属性

元素包含 全局属性

manifest 
指定一个 资源清单的URI,指示应在本地缓存的资源。请参阅 使用应用程序缓存 获取详细信息。
version 
指定控制当前文档的HTML版本文档类型定义 。这个属性已不再需要,因为这在文档类型声明中是多余的版本信息。
xmlns 

指派文档的 XML 命名空间。默认的值是"http://www.w3.org/1999/xhtml"。这在 XHTML 中是必要的,而在 HTML 中则是可选的。

示例

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

可访问性

html元素提供具有有效IETF标识语言标记lang属性,将有助于屏幕阅读技术确定要陈述的正确语言。标识语言标签应描述页面大部分内容使用的语言。没有它,屏幕阅读器通常会默认使用操作系统的设置语言,这可能会导致错误陈述。

规范

规范 状态 注释
HTML Living Standard
<html>
Living Standard (自上一次快照后没有改变)
HTML5
<html>
Recommendation 为manifest属性增加支持 (后来不赞成)。弃用 version 属性
HTML 4.01 Specification
<html>
Recommendation 不赞成 version 属性

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support YesEdge Full support YesFirefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
manifest
Deprecated
Chrome Full support 4Edge Full support YesFirefox Full support 3.5
Full support 3.5
Partial support 3
Notes
Notes Versions of Firefox prior to 3.5 ignore the NETWORK and FALLBACK sections of the cache manifest file.
IE Full support 10Opera Full support 10.6Safari Full support 4WebView Android Full support 4Chrome Android Full support 18Edge Mobile Full support YesFirefox Android Full support 4Opera Android Full support 11Safari iOS Full support 3.2Samsung Internet Android Full support Yes
version
Deprecated
Chrome Full support YesEdge Full support YesFirefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
xmlnsChrome Full support YesEdge Full support YesFirefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.
See implementation notes.
See implementation notes.

注意事项

  • 尽管在 HTML 里<html>元素不是必需的,可以是隐含的,但是在 XHTML 里必须明确给出它的开标签和闭标签。
  • 严格意义上,标签是指开始标签(例如 <p> 标签)或结束标签(例如 </p> 标签);元素(例如 p 元素或者称为<p>元素)则包括开始标签(自然也包括标签中定义的属性)、结束标签以及中间的内容(Content)。标签和元素的区别

相关链接

文档标签和贡献者

最后编辑者: eforegist,