<html>

Defines the root of an HTML document
2 min read
Believemy logo

The <html> tag is the root of an HTML document. It encapsulates all visible and invisible content of a webpage, defining the beginning and end of an HTML document. It is essential for browsers to properly interpret HTML code.

Warning

It does not fully encapsulate the entire page since it must be placed after the <!DOCTYPE html> declaration.

 

Structure of the HTML Tag

The <html> tag is a container tag (meaning it encloses other elements). It consists of two parts:

  1. The opening tag: <html>
  2. The closing tag: </html>

Thus, it is a tag that works in pairs.

 

Syntax

HTML
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Example HTML Page</title>
    </head>
    <body>
        <p>Long live Believemy!</p>
    </body>
</html>

As you can see, it is very important to add the lang attribute to your <html> tags.

This attribute allows you to specify the language of the page content, which is helpful for search engines, for instance.

This ensures that your page is correctly indexed by search engines! 😉

 

Attributes

lang

As mentioned above, the lang attribute specifies the language of the content on a page. It is critical for accessibility and search engines.

Good to know

This lang attribute is what allows browsers to display popups offering to translate a page! 😋

 

xmlns

The xmlns attribute (for XML Namespace) specifies the XML namespace used in the HTML document.

It is primarily required in XHTML documents to indicate that the content adheres to XML specification rules.

The default namespace is always http://www.w3.org/1999/xhtml.

Here’s a quick example:

HTML
<html xmlns="http://www.w3.org/1999/xhtml">
    ...
</html>

However, with the advent of HTML5, this attribute is no longer mandatory.

 

class / id

It is entirely possible to customize the CSS style of a page using the class and id attributes.

 

Compatibility

The <html> tag is compatible with all browsers.

ElementGoogle ChromeSafariMozilla FirefoxEdge
<html>YesYesYesYes

Related terms

Discover our hTML and CSS glossary

Browse the terms and definitions most commonly used in HTML and CSS development.

Share this article

Want to help us? Share this article on your networks or even better: on your site, in an article or in your newsletter.