html Element


 

Module

The html element is declared by the XHTML 1.1 Structure Module

Elements in the Structure Module are:
html | head | title | body

Description

The html element is used to enclose the entire XHTML document - apart from any XML Prolog (see the XML Declaration & DOCTYPE for more information).

This example shows the html element in context:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
   "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB">
  <head>
    <title>Page Title</title>
  </head>
  <body>
    <!--Your page content goes here-->
  </body>
</html>

Despite being declared in the DTD as a #FIXED attribute, rather than a #REQUIRED one, the xmlns attribute is actually compulsory on the html element in order for the document to pass W3C Validation. Its value is must be "http://www.w3.org/1999/xhtml" for every XHTML document. Inclusion of the xmlns attribute explicitly states the namespace name which applies to the document, without having to refer to the DTD.

Note: If the xmlns attribute is absent on the html element, this may result in the document's XHTML 1.1 status not being recognised in some user agents, with the specified function of each element being ignored and content being rendered simply, with no special behaviour for tables, lists or forms, no intrinsically block elements, etc etc.

Conversely, the #FIXED version attribute need not be included, perhaps because this information is available in the DOCTYPE declaration itself.

It is good practice to specify the language in which the document is written, using the xml:lang attribute. In the example above, the LanguageCode for British English, "en-GB", is used. If a document is written in more than one language, pick the main language - you can then add appropriate xml:lang attributes to those elements which contain text written in another language. You can add xml:lang attributes to almost any element you desire.
You may not think that it is important to include such language information as there is no visible effect of including it when viewing the page in a standard browser. It is invaluable information, however, for a screen reader for the blind, for example, as it can help with pronunciation. Search engines may also use language tags to classify content.

#REQUIRED Attributes

Although the xmlns attribute is declared as #FIXED and not #REQUIRED on the html element, it is compulsory in order for the document to pass W3C Validation.


Specific Attributes

Specific attributes of the html element are listed below:

From the Structure Module - the Element's own Module

version [ type FPI - #FIXED '-//W3C//DTD XHTML 1.1//EN' ]
An SGML Formal Public Identifier

Common Attributes

Common attributes of the html element are listed below:

From the Core Attribute Collection

Note: Even though the *XHTML 1.1 Structure Module DTD specifies that the id attribute is permitted on the html element, the *W3C Markup Validator does not currently recognise this and a document which uses this attribute on the html element will fail validation. I have therefore omitted the id attribute on the html element in this reference.

xmlns [ type URI - #FIXED 'http://www.w3.org/1999/xhtml' ]
XML namespace

From the I18N Attribute Collection

dir [ type Enumeration (ltr | rtl) ], from the Bi-directional Text Module
Left-to-right or right-to-left directionality
xml:lang [ type LanguageCode ]
A language code for the element

Content Model

The Content Model for the html element is:

head, body

NOTE: This element cannot be empty

See Content Model & Nesting for information about Content Model syntax and Nesting Groups.

Valid children of html

Valid parents of html

This is the root element and cannot have a parent.


Page Footer & Copyright

Copyright © Sally Maughan 2005-2009 (Page last updated on 01 Oct 2009)

*Valid XHTML 1.1 - hosted by *Openstrike

Content based on the W3C Working Draft: *XHTML 1.1 and Recommendation: *XHTML Modularisation 1.1.

W3C, XHTML, XML, HTML, CSS and MathML are *Trademarks of the W3C (*MIT, *ERCIM, *Keio) with which the site's author has no connection.


Up, Next & Previous Links

Your Location

Home > XHTML 1.1 Home > XHTML 1.1 Indexes > Element Index (XHTML 1.1) > html Element