HTML5 Global Attributes

A number of attributes are shared by all elements in HTML5 and are referred to collectively as the Global Attributes:

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"

Assigns one or more classification names to the element.

contenteditable="true|false"

Not in HTML 4.01. Indicates the user can edit the element. This attribute is already well supported in current browser versions.

contextmenu="id of menu element"

Not in HTML 4.01. Specifies a context menu that applies to the element. The context menu must be requested by the user, for example, by a right-click.

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"

Not in HTML 4.01. 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.

dropzone="copy|move|link|string:text string type|file:file type"

Not in HTML 4.01. Indicates what happens when a data is dragged onto the element and what kind of data to accept. 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 ...

Get HTML5 Pocket Reference, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.