XHTML/XHTML Documents

Basic XHTML documents
All XHTML documents follow a minimal pattern for document layout:

The  tag is the document type definition (described in the previous chapter) that identifies the standard being used.

The  tag pair is the root tag that specifies an XHTML document. It requires two tags: the  is the namespace tag that restates the specific context of the standard, and is normally a URL to the W3 specification. The  tag specifies the language of the document.

The  tag pair of the document concerns the meta data of the document. It must contain the title of the document enclosed within the  tags.

The  tag pair indicates the main content of the XHTML document. Within this tag, it encloses additional sub-tags to indicate paragraphs and other formatting information that is presented to the user.

XHTML Structure
Within the body of the html document, content is broken into a discrete structure. The most common form of separation involves the  tag pair, which marks a section of text as a paragraph. A paragraph is a section of text, and may also also include quotes, listings or other components that are contained in nested tags. However, it does not directly contain another paragraph.

Headers of text are identified the numbered series ranging from  through. They may also be identified by  tag pair, in combination with the   tag pair; the sections may contain additional headers or paragraphs.

Additional structure to the document can be created using the. This tag pair is used to aid layouts within the document, and may contain additional paragraphs or headers within the container.

To separate two parts of the document, the  is places between two paragraphs or elements.

Other structure tags

 * is used to mark contact information, normally with the  attribute.
 * is used to mark a block of code where whitespaced layout is important.
 * is used to identify a large quotation.
 * is used to identify preformatted text.

Inline text tags
A set of text within text may have tags to describe modifiers to the text.

Hyperlinking
Hyperlinks work in XHTML in the same manner as HTML. An  attribute is added to the an anchor element:

In XHTML 2.0, hyperlinks be placed directly on any element without the need of an anchor tag. As such, elements such as images can be used for a hyperlink.

Image maps
A more advanced form of hyperlinking involved navigation maps. This requires an element to use an image, and to include the  attribute to reference an id of a navigation map. Within the navigation list, there are two additional attributes to use:, and. The coordinates are comma-delimited.

Within the navigation list, items apparing first within the list take priority if they overlap with another entry in the navigation map. In addition, navigation lists that do not include an href attribute will be inactive.

If  is used on the image attribute, the image map is treated as a server-side map. The client will automatically append the coordinates to the URL sent to the server on this form of map (or "0,0" if they are unable to do so.)

Tables
Tables are created in an XHTML document using the  tag pair. A table is a grid of cells that is displayed.

Within a table, the  and   tags are used to specify a formatting or class to a set of columns. These two tags, which allow the  attribute, will cause a given column of cells to obtain a specific format (such as background colour or style sheet).

The  tag pair is used to provide a summary of the table. This is usually a caption about the table, such as a brief description about the table itself.

The  tag pair identifies the body of the table. It will enclose the row and cell tags that will be described shortly.

The  tag pair identifies a row within the table. Each pair of this tag will contain the cell definitions, whether they are a header or content cell.

The  tag pair identifies a cell within a table. The  tag pair identifies a cell within a table, which is treated as a header and given emphasis. Cells may span multiple columns or rows with the  or   attribute. Some cells may require uting an abbreviation, which is performed using the  attribute.

The  tag pair identifies the table's header.

The  tag pair identifies the table's footer.

Stylesheets
Style sheets give a description on how to render an XHTML document. Style sheets are not a direct part of the XHTML standard, but are extremely important for determining the layout or display of the document.

They are declared using an empty  tag, and use the   attribute for the document source and   to specify the type of style sheet (usually "text/css"). An inline style sheet omits the  attribute and contains the affected text within the main element.

External stylesheets may also be included by using  with the   and   showing the source and type of stylesheet.

If desired, a style can be included directly within an HTML element using the  attribute.

Metadata
The  tag pair contains the initial description of the document. In addition to the basic title, this section of the document contains metadata useful for categorizing the document.

Meta data has the following attributes available:

Metadata also provides properties that describe additional information in the document. When the property attribute is set to an entry in the following table, it has the following effect or result:

Meta hyperlinks
In the head tag, you can include hyperlinks to provide information about the next and previous documents. This is done using an empty  tag, with the   and   attribute.