4. The elements of HTML
4.1. The root element
4.1.1. The html
#elementdef-htmlReferenced in:1.9. A quick introduction to HTML (2)3.1.3. DOM tree accessors (2) (3) (4)3.2.5.3.
The lang and xml:lang attributes 3.2.5.6. The dir attribute (2) (3) (4)4.1.1. The html element (2) (3) (4) (5) (6) (7) (8)4.2.1. The head element4.3.1. The body element (2)4.7.6. The iframe element (2)6.1. Browsing contexts6.7.6. Page load processing model for media (2)6.7.7. Page load processing model for content that uses plugins (2)8.1. Writing HTML documents (2) (3) (4) (5) (6)8.1.2.4. Optional tags (2) (3) (4) (5) (6) (7) (8)8.2.3.1. The insertion mode8.2.3.2. The stack of open elements (2) (3) (4) (5)8.2.5.1. Creating and inserting nodes8.2.5.4.2. The "before html" insertion mode8.2.5.4.7. The "in body" insertion mode (2) (3) (4)8.2.5.4.9. The "in table" insertion mode (2)8.2.5.4.13. The "in table body" insertion mode (2)8.2.5.4.14. The "in row" insertion mode (2)8.2.5.4.19. The "after body" insertion mode8.2.5.4.20. The "in frameset" insertion mode (2) (3)8.2.8.1. Misnested tags: <b><i></b></i> (2) (3) (4)8.2.8.2. Misnested tags: <b><p></b></p> (2) (3) (4) (5) (6)8.2.8.3. Unexpected markup in tables (2) (3) (4) (5) (6) (7) (8) (9) (10) (11)8.2.8.4. Scripts that modify the page as it is being parsed (2) (3)8.2.8.6. Unclosed formatting elements8.4. Parsing HTML fragments11.2. Non-conforming features11.3.4. Other elements, attributes and APIsElements (2) (3)Element Interfaces element
- Categories:
- None.
- Contexts in which this element can be used:
- As the root element of a document.
- Wherever a subdocument fragment is allowed in a compound document.
- Content model:
- A
head
element followed by abody
element. - Tag omission in text/html:
- An
html
element’s start tag can be omitted if the first thing inside thehtml
element is not a comment. - An
html
element’s end tag can be omitted if thehtml
element is not immediately followed by a comment. - Content attributes:
- Global attributes
- Allowed ARIA role attribute values:
- None
- Allowed ARIA state and property attributes:
- Global aria-* attributes
- DOM interface:
-
interface HTMLHtmlElement#htmlhtmlelement-htmlhtmlelementReferenced in:11.3.4. Other elements, attributes and APIsElementsElement Interfaces : HTMLElement {};
The html
element represents the root of an HTML document.
Authors are encouraged to specify a lang
attribute on the root html
element, giving
the document’s language. This aids speech synthesis tools to determine what pronunciations to use,
translation tools to determine what rules to use, and so forth.
It is recommended to keep the usage of attributes and their values defined on the html
element to a minimum to allow for proper detection of the character encoding declaration within the first 1024 bytes.
The
html
element in the following example declares that the document’s language is
English.
<!DOCTYPE html> <html lang="en"> <head> <title>Swapping Songs</title> </head> <body> <h1>Swapping Songs</h1> <p>Tonight I swapped some of the songs I wrote with some friends, who gave me some of the songs they wrote. I love sharing my music.</p> </body> </html>