The <html> tag for HTML 5

The <html xmlns="http://www.w3.org/1999/xhtml"> tag includes the HTML namespace declaration.

The <html> tag is the tag for the top element of an HTML document. The parent of the html element is the root node of the DOM.

Inside the html element is the head element and the body element. One purpose of these elements is to separate the page title and other metadata information in the head section from the actual visible content of the document in the body section.

<html xmlns="http://www.w3.org/1999/xhtml">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

The <html> tag includes an xmlns attribute that specifies the HTML namespace assigned in 1999 for the year 2000 and later versions of HTML. Namespace partitions are needed to avoid naming collisions for element types in a schema (or DTD), especially if it can be used for content that may be integrated or aggregated with other content. Element types with the same name in different namespaces have completely separate definitions.

It is important for element names to be associated with the correct namespace when tags are being processed by a parser or script, using the Document Object Model or CSS for example, so the element is interpreted as the correct element type. If an element is interpreted using the wrong element type definition, the attributes and child elements will not properly match up with the element's properties and content model. (See the difference between attributes and properties if those terms are unclear.)

The HTML elements will be in the http://www.w3.org/1999/xhtml namespace by default in documents that are being parsed as HTML, so the xmlns attribute is optional ... in that case only. When the document is being parsed as xHTML, the XHTML-compatible serialization of HTML, or as pure XML, however, the xmlns attribute is required. Therefore, it is recommended that xmlns="http://www.w3.org/1999/xhtml" should always be included on the <html> tag, since it is the parser that determines how to interpret a document.

When xmlns="http://www.w3.org/1999/xhtml" is required
When HTML Is Parsed Asxmlns required?
HTMLNo it is assumed
xHTMLYes, it is required
Pure XMLYes, it is required

See the HTML Namespace Tutorial for more information on namespaces in HTML.