HyperText Markup Language/Tag List/html

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Use[edit | edit source]

html wraps the whole HTML document. The opening tag is placed directly after the doctype declaration, the end tag at the end of the document.

It is recommended that the primary language of the document is indicated with either the lang attribute for HTML or the xml:lang attribute for XHTML. XHTML 1.0 documents served with a MIME type of text/html should use both lang and xml:lang.

Example[edit | edit source]

An English language HTML 4.01 document.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
  <head>
    <title>Example page</title>
  </head>
  <body>
    <p>Example paragraph.</p>
  </body>
</html>

An English language XHTML 1.0 document.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Example page</title>
  </head>
  <body>
    <p>Example paragraph.</p>
  </body>
</html>

Required attributes[edit | edit source]

xmlns[edit | edit source]

In XHTML 1.0 and XHTML 1.1 xmlns is required. xmlns defines the XML namespace. Its value in XHTML 1.0 and XHTML 1.1 is http://www.w3.org/1999/xhtml.

Standard attributes[edit | edit source]

Notes[edit | edit source]

This tag is optional in HTML 4.01, but it is strongly recommend to use it.

It is required in XHTML.

More info[edit | edit source]

The HTML element in HTML 4.01 Specification
The <html> tag on W3Schools