HTML5 Global Attributes
HTML attributes give elements meaning and context. A number of attributes are shared by all elements in HTML5 and are referred to collectively as the Global Attributes: |
HTML5 Global Attributes:
Attribute | Description |
---|---|
accesskey="character" | Assigns an access key (shortcut key command) that activates or focuses the element. The value is a single character. Users may access the element by hitting Alt-<key> (PC) or Ctrl-<key> (Mac). |
class="text string" | Specifies one or more classnames for an element (refers to a class in a style sheet) |
contenteditable="true|false" | Indicates the user can edit the element. This attribute is already well supported in current browser versions. Not in HTML 4.01. |
contextmenu="id of menu element" | Specifies a context menu that applies to the element. The context menu must be requested by the user, for example, by a right-click. Not in HTML 4.01. |
dir="ltr|rtl|auto" | Specifies the direction of the element. ltr indicates left to right; rtl indicates right to left; and auto indicates that direction should be determined programmatically. |
draggable="true|false" | Indicates the element is draggable, meaning it can be moved by clicking and holding on it, and then moving it to a new position in the window. Not in HTML 4.01. |
dropzone="copy|move|link|string:text string type| file:file type" | Specifies whether the dragged data is copied, moved, or linked, when dropped. copy results in a copy of the dragged data; move moves the data to a new location; and link results in a link to the original data. Including string:text/plain allows it to accept any text string. The file: attribute indicates what type of file is accepted (e.g., file:image/png). Both the action and accepted data may be provided, for example, dropzone="copy string:text/plain". Not in HTML 4.01. |
hidden (hidden="hidden" in XHTML) | Prevents the element and its descendants from being rendered in the user agent (browser). Any scripts or form controls in hidden sections will still execute, but they will not be presented to the user. Not in HTML 4.01. |
id="text string" | Specifies a unique id for an element. |
inert (inert="inert" in XHTML) | Indicates that the element should be made inert, which means it cannot be selected, searched, or targeted by user interactions. WHATWG* & HTML5.1 only. |
itemid="text" | Part of the microdata system for embedding machine-readable data, the itemid attribute indicates a globally recognized identifier (such as an ISBN for a book). It is used in conjunction with itemtype in the same element containing itemscope. WHATWG* & HTML5.1 only. |
itemprop="text" | Part of the microdata system for embedding machine-readable data, the itemprop attribute provides the name of the property. The content of the element provides its value. The value may also be a URL provided by the href attribute in a elements or the src attribute in img. WHATWG* & HTML5.1 only. |
itemref="space-separated list of IDs" | Part of the microdata system for embedding machine-readable data, the itemref attribute specifies a list of elements (by ID values) on the current page to be included in an item. The itemref attribute must be used in the same element as the itemscope attribute that established the item. WHATWG* & HTML5.1 only. |
itemscope |
Part of the microdata system for embedding machine-readable data, itemscope creates a new item, a group of properties (name/value pairs). WHATWG* & HTML5.1 only. |
itemtype="URL or reversed DNS label" |
Part of the microdata system for embedding machine-readable data, the item type attribute indicates a standardized itemtype indicated by a URL or a reversed DNS label. The itemtype attribute is used in the same element containing the itemscope attribute. WHATWG* & HTML5.1 only. |
lang | Specifies the language of the element's content |
xml:lang | Specifies language for elements in XHTML documents. XHTML only. |
spellcheck="true|false" |
Specifies whether the element is to have its spelling and grammar checked or not. Not in HTML 4.01. |
style="CSS styles" | Specifies an inline CSS style for an element |
tabindex="number" |
Specifies the position of the current element in the tabbing order for the current document. The value must be between 0 and 32,767. It is used for tabbing through the links on a page (or fields in a form). |
title="text string" | Specifies extra information about an element |
translate="yes|no" | Indicates whether the element's text content and attribute values should be translated when the document is localized. yes is the default; no leaves the element content unchanged. Not in HTML 4.01. |
*WHATWG: Web Hypertext Application Technology Working Group.
<< Example of incorporations and improvements from previous versions |