HTML / HTML Tags

HTML <Html> Tag

Dec 12, 2022
2 min read
HTML html Tag

Definition

The <html> tag represents the root, or top-level, element of an HTML document. It is often referred to as the root element as other elements must be descendants.

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <title>HTML Title Element goes here.</title>
</head>
<body>
    <h1>Displayed Page Title</h1>
    <p>The main content of your page goes here.</p>
</body>
</html>

Usage

  • A <html> element may content one <head> element and one <body> element.
  • No parent elements are allowed as this is the root element of a document.
  • The start tag can be omitted if the first item inside the <html> is not a comment.
  • The closing <html> tag can be omitted if it is not immediately followed by a comment.

Attributes

The <html> element only supports the Global Attributes.

Best Practices

  • You should use a lang attribute so that screen readers can easily identify the correct language. It also assists search engines and browsers, for example, with auto-translate.
  • You should keep the use of attributes and associated values defined on the <html> element to a minimum. This allows for proper detection of the character encoding declaration (e.g. <meta charset="utf-8"/>) within the first 1024 bytes.

Specification

Browser Support

Desktop

ChromeEdgeFirefoxIEOperaSafari
YesYesYesYesYesYes

Mobile

Android WebviewChrome AndroidFirefox AndroidOpera AndroidiOS SafariSamsung Internet
YesYesYesYesYesYes