Skip to content

HTML <html> Tag

The <html> tag is a root element of an HTML document. It contains all HTML elements that inform the browser that this is an HTML document. Before the <html> tag we must put only the <!DOCTYPE> declaration, which informs about the HTML version used in the document.

The child elements of the <html> tag are:

  • The <head> tag which contains technical information for browsers enclosed in <title>, <script>, <link> and other tags).
  • The <body> tag which defines the content of an HTML document (text, images, links, etc.).

TIP

We recommend using the <html> tag with the lang attribute, which defines the language of the document. It simplifies the indexing of a web page, helps browsers to correctly display national characters, and devices that read from the screen to correctly determine the pronunciation.

HTML <html> Tag with the "lang" attribute

html
<html lang="en">

Syntax

The <html> tag comes in pairs. The content is written between the opening (<html>) and closing (</html>) tags. Note: In HTML5, the closing </html> tag is optional.

Example of the HTML <html> tag:

HTML <html> Tag

html
<!DOCTYPE html>
<html lang="en">
   <head>
      <title>Title of the document</title>
   </head>
   <body>
      The content of the page
   </body>
</html>

Result

html tag  example

Attributes

AttributeValueDescription
manifestURLSpecifies the URL of the resource where the manifest is located with the list of resources that should be cached in the user's browser (for offline viewing). (Obsolete in HTML5)
xmlnshttps://www.w3.org/1999/xhtmlSpecifies the XML namespace for the document (if the XHTML document correspondence is required). Required in XHTML. In HTML5 it isn’t required.

The <html> tag supports the Global Attributes and Event Attributes.

Practice

What is the function of the HTML <html> tag?

Dual-run preview — compare with live Symfony routes.