B. HTML5 Global Attributes

B

HTML5 Global Attributes

The following attributes may be used with any HTML element.

Attribute

Values

Description

accesskey
single text character

Assigns an access key (shortcut key command) to the link. Access keys are also used for form fields. Users may access the element by pressing Alt-<key> (PC) or Ctrl-<key> (Mac). Example: accesskey="B"

class
text string

Assigns one or more classification names to the element. Multiple values are separated by spaces.

contenteditable

true | false

Indicates the user can edit the element. If the value is an empty string, it is the same as “true.” By default, the element inherits the edit setting from its parent.

dir

ltr | rtl | auto

Specifies the inline text direction of the element (“left to right” or “right to left”) and scopes bidirectional reordering, isolating the text from influencing surrounding content. When set to auto, it uses the first letter to determine direction.

draggable

true | false

A true value indicates the element is draggable in the UI (an event configured with JavaScript), meaning the user can move it by clicking and holding it, and then moving it to a new position in the window.

hidden

In HTML, list value only: hidden

In XHTML, include attribute name: hidden="hidden"

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 will not be presented to the user.

id

text string (may not contain spaces)

Assigns a unique identifying name to the element.

lang

ISO language code (see )

Specifies the primary language for the content of an element and its attribute values. When lang is omitted, the language of the element is the same as the language of the parent element.

spellcheck

true | false

Indicates whether the element is to have its spelling and grammar checked. When spellcheck is omitted, the element follows the default behavior for that element, possibly inheriting the parent’s spellcheck state.

style

Semicolon-separated list of style rules (property: value pairs)

Associates style information with an element. For example:

<h1 style="color: red; border: 1px solid">Heading</h1>
tabindex
number

Indicates that the element is focusable, and specifies its position in the tabbing order for the current document. The value must be between 0 and 32,767. It is used for tabbing through links on a page or fields in a form and is useful for assistive browsing devices. A value of –1 is allowable to remove elements from the tabbing flow and make them focusable only by JavaScript.

title
text string

Provides a title or advisory information about the element, typically displayed as a tooltip. If a title is not specified, an element inherits the title from its nearest ancestor element with a title.

translate

yes | no

Specifies whether an element’s attribute values and the values of its Text node children are to be translated when the page is localized, or whether to leave them unchanged. If it is not specified, the element inherits the translate state from its parent.