Xhtml Reference
generally supported elements and associated attributes. This is not intended as an exhaustive guide; rather, its aim is to list those elements important and relevant to current web design. Archaic deprecated elements such as font and layer are therefore ignored, as well as many attributes once associated with the body element
Standard attributes
Standard attributes are common to many elements. For brevity, they are listed in full here rather than in the XHTML element table later in the chapter. For each element in the forth- coming table, I simply state which groups of standard attributes are applicable to the element.
Core attributes
Attribute |
Description |
class=classname |
Specifies a CSS class to define the element’s visual appearance. |
id=name |
Defines a unique reference ID for the element. |
style=style |
Sets an inline style. Deprecated in XHTML 1.1, so it should be |
title=string |
Specifies the element’s title. Often used with links to provide a |
Keyboard attributes
Attribute |
Description |
accesskey=character |
Defines a keyboard shortcut to access an element. The short- |
tabindex=number |
Defines the tab order of an element. Most commonly used |
Language attributes
Attribute |
Description |
dir=dir |
Specifies the text rendering direction: left-to-right (ltr, the |
lang=language |
Specifies the language for the tag’s contents, using two-letter |
xml:lang=language |
Replaces lang in XHTML 1.1, but both should be used |
Event attributes
As of HTML 4.0, it’s been possible to trigger browser actions by way of HTML events. Again, these are listed in full here and referred to for the relevant elements of the XHTML ele- ment table. In XHTML, all event names must be in lowercase (e.g., onclick, not onClick).
Core events
Attribute |
Description |
onclick=script |
Specifies a script to be run when the user clicks the ele- |
ondblclick=script |
Specifies a script to be run when the user double-clicks the |
onkeydown=script |
Specifies a script to be run when the user presses a key while |
onkeypress=script |
Specifies a script to be run when the user presses and |
onkeyup=script |
Specifies a script to be run when the user releases a pressed |
onmousedown=script |
Specifies a script to be run when the user presses down |
onmousemove=script |
Specifies a script to be run when the user moves the mouse |
| onmouseout=script | Specifies a script to be run when the user moves the mouse |
| onmouseover=script | Specifies a script to be run when the user moves the mouse |
onmouseup=script |
Specifies a script to be run when the user releases the mouse |