12. XHTML Core Attributes Module

Contents

This section is normative.

This module defines the Core attribute collection.

12.1. Core Attribute Collection

class = NMTOKENS
This attribute assigns one or more class names to an element; the element may be said to belong to these classes. A class name may be shared by several element instances.

The class attribute can be used for different purposes in XHTML, for instance as a style sheet selector (when an author wishes to assign style information to a set of elements), and for general purpose processing by user agents.

For instance in the following example, the p element is used in conjunction with the class attribute to identify a particular type of paragraph.

Example

<p class="note">
These programs are only available if you have purchased
the advanced professional suite.
</p>

Style sheet rules can then be used to render the paragraph appropriately, for instance by putting a border around it, giving it a different background color, or where necessary by not displaying it at all.

It is good style to use names that represent the purpose of the element rather than the visual presentation to be used. For instance don't use class="red", but rather class="urgent", or similar.

id = ID
The id attribute assigns an identifier to an element. The id of an element must be unique within a document.

The id attribute has several roles in XHTML:

As an example, the following headings are distinguished by their id values:

Example

<h id="introduction">Introduction</h>
<p>...</p>
<h id="events">The Events Module</h>
<p>...</p>
layout = irrelevant*|relevant
This attribute allows authors to indicate whether the whitespace within an element is relevant to the meaning of the content or not; for instance, visual user agents could display the whitespace. The default is that it is irrelevant. Some elements, notably pre override this default. See whitespace handling in the section on XHTML Family User Agent Conformance for more information.

Example

<p class="poem" layout="relevant">
(with wee ears and see?

tail frisks)
              (gonE)
</p>
title = Text
This attribute defines meta-information about the element on which it is set.

Example

<a href="Jakob.html" title="Author biography">Jakob Nielsen</a>'s Alertbox for January 11, 1998

Implementation: RELAX NG