id Attribute


 

Where to use the id Attribute

id is a Common Attribute from the Core Attribute Collection and is of Type ID.

It may be used on most elements in the Element Index - all except: base, head, html, meta, title. It is #REQUIRED on the map element.
Note: Although the id attribute is seemingly permitted by the *XHTML 1.1 Structure Module DTD on the html and head elements, its presence on these elements currently causes a page to fail W3C Validation and so they are not considered valid in this reference.


Description

The id attribute can be used on almost any element (see above) to specify a unique identifier for that element. This id may then be referenced, for example, within a script or CSS stylesheet or possibly by another XHTML element which has an attribute of type IDREF or IDREFS.

Important notes about id attributes:
  1. The identifier must follow the format specified for the ID Attribute Type (e.g. must not begin with a digit).
  2. Any single element may not have more than one id and each such value must be unique to the document.
  3. If compatibility is desired with HTML 4 identifiers, the ID value must match the regular expression [a-zA-Z][a-zA-Z_:.-]* (see *HTML 4.01 - SGML basic types)
  4. If compatibility is desired with CSS identifiers, the W3C's *CSS 2.1 - Characters and Case information should be noted.

See also the class attribute.


Page Footer & Copyright

Copyright © Sally Maughan 2005-2009 (Page last updated on 16 May 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 > Attribute Index (XHTML 1.1) > id Attribute (XHTML 1.1)