HTML reference

html

The <html> element is the root of an HTML document. Every other HTML element belongs inside it, usually split into <head> and <body>.

What you will learn

  • Why <html> is the document root
  • What the lang and dir attributes do
  • How head and body fit inside it

Basic structure

<!doctype html>
<html lang="en">
  <head>
    <title>Page title</title>
  </head>
  <body>
    <h1>Visible content</h1>
  </body>
</html>

Useful attributes

lang
Declares the main language of the document, such as en or ja. This helps screen readers and other tools choose pronunciation and language rules.
dir
Sets text direction: ltr, rtl, or auto. It is useful for right-to-left languages.

Remember

Put metadata in <head> and visible page content in <body>. Set an accurate lang value instead of leaving the document language unknown.

Related pages