Description

HTML element <html> is used to define the root of an HTML document, which includes the head and body elements.

The element <html> is the container for all the elements except the <!DOCTYPE> which is however a declaration and not an element.

It is always suggested to include the language attribute to define the kind of language used for document content, which assists both browsers and search engines.

The below table summarizes its usage.

Usage Details
Placement It is the root element of an HTML document.
Contents It can contain the elements <head>, and <body>.
Tags Both opening and closing tags are required.
Versions HTML 2, 3.2, 4, 4.01, 5

Syntax

Here is the basic syntax of the <html> element.

<html>...</html>

Examples

In the below example, the <html> element is used to define the root of an HTML document along with the language attribute.

<!DOCTYPE html>
<html lang="en">
<head>
        <!-- Document head goes here -->
</head>
<body>
        <!-- Document body goes here -->
</body>
</html>

Attributes

The following table shows the list of supported and unsupported attributes for the <html> tag.

Attribute Type Details
Element-Specific Attributes The tag <html> has some element-specific attributes listed in the below table.
Global Attributes Like all other HTML tags, the tag <html> supports the HTML Global Attributes.
Event Attributes The tag <html> also supports the HTML Event Attributes.

Here is a list of attributes that are specific to the <html> element.

Attribute Value Description
manifest URL Specifies the URL of the document's cache manifest (for offline application).
version DTD Obsolete and Not to be used.
Specifies which HTML DTD version governs the current document.
xmlns http://www.w3.org/1999/xhtml XHTML only.
Specifies the URL of the default XML namespace for a document in case needed to confirm to XHTML.

Browser Compatibility

The tag <html> is supported in all modern browsers.

  • Google Chrome 1+
  • Internet Explorer or Edge 2+
  • Firefox 1+
  • Apple Safari 1+
  • Opera 2.1+

Related Links