HTML Tags

HTML <html> Tag

The <html> tag is the root element that wraps all other elements on the page and represents the whole document.


What is the <html> tag?

The <html> element is the top-level element of an HTML document, often called the root element. Every other element must be a descendant of it. A document contains exactly one <html> element, which itself contains one <head> followed by one <body>.

Syntax

The <html> element wraps the entire document.
<html lang="en">
  <!-- head and body go here -->
</html>

Complete example

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Root Element Demo</title>
  </head>
  <body>
    <p>Everything you see lives inside the html element.</p>
  </body>
</html>

Attributes

AttributeDescription
langDeclares the primary language of the document (for example en, hi, fr). Helps screen readers, search engines, and translation tools.
dirSets the base text direction: ltr (left-to-right) or rtl (right-to-left).
xmlnsThe XML namespace, used only when serving the document as XHTML.
💡

Always set the lang attribute. It improves accessibility and SEO, and it is required for valid, high-quality HTML.

The <html> tag is supported in all browsers. The opening and closing tags are technically optional in the HTML syntax, but you should always include them for clarity and tooling support.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships