XML technologies / HTML & XHTML / Common attributes and events
(Excerpt from "HTML & XHTML ─ kurz & gut" by Jennifer Niederst Robbins)
Several attributes can be used on almost all elements. We use the same abbreviations as the W3C recommendations. This page serves as a reference for the “Alphabetical list of HTML and XHTML elements” and explains the abbreviations for individual attributes.
In HTML 4.01 and XHTML 1.0, attributes and events belong to one of the groups Core, Internationalization (Internationalization), focus (Focus) and events. HTML 5 instead provides a set of global attributes (Global Attributes) applicable to all HTML elements.
HTML 4.01 and XHTML 1.0
Core
When the term Core appears under attributes, it means the core attributes applicable to most elements, as noted in each entry:
idAssigns a unique identifier to the element.
classAssigns one or more class names to the element.
styleAssigns specific styling information (CSS) to an element.
titleContains a title or additional information about the element.
Internationalization
If the attribute list includes the term Internationalization the following language and reading-direction attributes can be defined for the element:
dirSpecifies the element’s reading direction, left to right or the reverse.
langSpecifies an element’s language using a language code.
xml:langXHTML only. Specifies the language of elements in an XHTML document.
focus
focus means that an element, such as a link or form control, is selected and ready for input. Where focus is specified, the following focus attributes and events can apply to the element:
accesskey="character"Assigns a keyboard shortcut to a link or form field. Its value is one character. Users can access the marked element using Alt-<Zeichen> (PC) or Ctrl-<Zeichen> (Mac).
onblurThe element loses focus through pointer movement or pressing the Tab key.
onfocusThe element receives focus through pointer movement or pressing the Tab key.
tabindex="Zahl"Specifies the element’s position in the document’s tab order. Valid values range from 0 to 32,767. With this attribute, users can move through links or form fields using the Tab key.
events
If events are listed for an element, the core scripting events apply. Other events outside the core are listed separately:
onclickAn element is clicked.
ondblclickAn element is double-clicked.
onkeydownA key is pressed while the element is active, for example after being clicked.
onkeypressA key is pressed and released while the element is active.
onkeyupA key is released while the element is active.
onmousedownA mouse button is held down over the element.
onmousemoveThe pointer moves while over the element.
onmouseoutThe pointer moves away from the element.
onmouseoverThe pointer moves onto the element.
onmouseupA mouse button is released over the element.
HTML 5
Global attributes
In addition to the attributes id, class, style, title, dir, lang, accesskey and tabindex, inherited from HTML 4.01, HTML 5 defines the following global attributes, applicable to all elements:
contenteditable="true|false"Indicates that the user can edit the element. Many current browsers already support this attribute.
contextmenu="ID des Menüelements"Refers to a context menu for the element. The user must invoke it, for example by right-clicking.
draggable="true|false"Specifies whether the element can be dragged and dropped to a new window position with the mouse.
hidden(hidden="hidden"in XHTML)Prevents the browser from displaying the element and its descendants. Scripts and form elements in the hidden portion still run but are not shown to the user.
itemid="Text"Part of the microdata system for embedding machine-readable data. The attribute
itemidmarks a globally recognized identifier, such as a book’s ISBN. It is used with the attributeitemtypein the same document, which also contains the attributeitemscope.itemprop="Text"Part of the microdata system for embedding machine-readable data. The attribute
itempropspecifies the name of aproperty. The element’s content determines the attribute value. The value can also be a URL specified by the attributehrefin aaelement or by the attributesrcin theimgelement.itemref="durch Leerzeichen getrennte Liste mit IDs"Part of the microdata system for embedding machine-readable data. The attribute
itemrefspecifies elements on the current page, listed by ID, to include in an item. The attributeitemrefmust be used on the same element as theitemscopeattribute declaring the item.itemscopePart of the microdata system for embedding machine-readable data. The attribute
itemscopecreates a new item. This is a group of properties, or name/value pairs.itemtype="URL oder umgekehrtes DNS-Label"Part of the microdata system for embedding machine-readable data. The attribute
itemtypeuses a URL ("http://vocab.example.net/book") or a reversed DNS label (for example "com.example.person") to identify a standardized item type. The attributeitemtypeis used on the same element as the attributeitemscope.spellcheck="true|false"Specifies whether spelling and grammar are checked for the element.
HTML 5 event handlers
Unless otherwise noted, the following event handlers can be used with any HTML 5 element:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Note: onblur, onerror, onfocus and onload behave slightly differently when applied to the body element element, since body inherits these event handlers from its parent window.
*Event handlers for the object Window, when used with the body element.
Copyright © 2010 O’Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from "HTML & XHTML ─ kurz & gut" is subject to the same provisions as the printed edition: the work, including all its parts, is protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de