HTML5 Global Attributes
The HTML5 global attributes can be applied on all elements.
Global Attributes in HTML5
In addition to the element specific attributes, the HTML5 defines few attributes that are common to all elements. These attributes may be specified on all elements, with some exceptions where it is not relevant, such as elements found inside the <head>
section of the document, e.g. <base>
, <script>
, <title>
etc.
Attribute | Value | Description |
---|---|---|
accesskey |
shortcut key | Specifies a keyboard shortcut to activate or focus the element. |
class |
classname | Assigns a class name or space-separated list of class names to an element. |
contenteditable |
true false |
Indicates whether the content of an element is editable by the user or not. |
contextmenu |
menu-id | Specifies a context menu for an element. A context menu is a menu that appears when the user clicks the right mouse button on the element. |
data-* |
data | Specified on any HTML element, to store custom data specific to the page. |
dir |
ltr rtl |
Specifies the base direction of directionality of the element's text. |
draggable |
true false |
Specifies whether an element is draggable or not. |
dropzone |
copy move link |
Specifies whether the dragged data is copied, moved, or linked, when dropped. |
hidden |
hidden |
Indicates that the element is not yet, or is no longer, relevant. |
id |
name | Specifies a unique identifier (ID) for an element which must be unique in the whole document. |
lang |
language-code | Specifies the primary language for the element's text content. |
spellcheck |
true false |
Specifies whether the element may be checked for spelling errors or not. |
style |
style | Specifies inline style information for an element. |
tabindex |
number | Specifies the tabbing order of an element. |
title |
text | Provides advisory information related to the element. It would be appropriate for a tooltip. |
translate |
yes no |
Specifies whether the text content of an element should be translated or not. |
xml:lang |
language-code | Specifies the primary language for the element's text content, in XHTML documents. |