This is a snapshot of an early working draft and has therefore been superseded by the HTML standard.

This document will not be further updated.

HTML 5

Call For Comments — 27 October 2007

3.4. Global attributes

The following attributes are common to and may be specified on all HTML elements (even those not defined in this specification):

Global attributes:
class
contenteditable
contextmenu
dir
draggable
id
irrelevant
lang
ref
registrationmark
tabindex
template
title

In addition, the following event handler content attributes may be specified on any HTML element:

3.4.1. The id attribute

The id attribute represents its element's unique identifier. The value must be unique in the subtree within which the element finds itself and must contain at least one character. The value must not contain any space characters.

If the value is not the empty string, user agents must associate the element with the given value (exactly, including any space characters) for the purposes of ID matching within the subtree the element finds itself (e.g. for selectors in CSS or for the getElementById() method in the DOM).

Identifiers are opaque strings. Particular meanings should not be derived from the value of the id attribute.

This specification doesn't preclude an element having multiple IDs, if other mechanisms (e.g. DOM Core methods) can set an element's ID in a way that doesn't conflict with the id attribute.

The id DOM attribute must reflect the id content attribute.

3.4.2. The title attribute

The title attribute represents advisory information for the element, such as would be appropriate for a tooltip. On a link, this could be the title or a description of the target resource; on an image, it could be the image credit or a description of the image; on a paragraph, it could be a footnote or commentary on the text; on a citation, it could be further information about the source; and so forth. The value is text.

If this attribute is omitted from an element, then it implies that the title attribute of the nearest ancestor with a title attribute set is also relevant to this element. Setting the attribute overrides this, explicitly stating that the advisory information of any ancestors is not relevant to this element. Setting the attribute to the empty string indicates that the element has no advisory information.

If the title attribute's value contains U+000A LINE FEED (LF) characters, the content is split into multiple lines. Each U+000A LINE FEED (LF) character represents a line break.

Some elements, such as link and dfn, define additional semantics for the title attribute beyond the semantics described above.

The title DOM attribute must reflect the title content attribute.

3.4.3. The lang (HTML only) and xml:lang (XML only) attributes

The lang attribute specifies the primary language for the element's contents and for any of the element's attributes that contain text. Its value must be a valid RFC 3066 language code, or the empty string. [RFC3066]

The xml:lang attribute is defined in XML. [XML]

If these attributes are omitted from an element, then it implies that the language of this element is the same as the language of the parent element. Setting the attribute to the empty string indicates that the primary language is unknown.

The lang attribute may only be used on elements of HTML documents. Authors must not use the lang attribute in XML documents.

The xml:lang attribute may only be used on elements of XML documents. Authors must not use the xml:lang attribute in HTML documents.

To determine the language of a node, user agents must look at the nearest ancestor element (including the element itself if the node is an element) that has a lang or xml:lang attribute set. That specifies the language of the node.

If both the xml:lang attribute and the lang attribute are set on an element, user agents must use the xml:lang attribute, and the lang attribute must be ignored for the purposes of determining the element's language.

If no explicit language is given for the root element, then language information from a higher-level protocol (such as HTTP), if any, must be used as the final fallback language. In the absence of any language information, the default value is unknown (the empty string).

User agents may use the element's language to determine proper processing or rendering (e.g. in the selection of appropriate fonts or pronounciations, or for dictionary selection).

The lang DOM attribute must reflect the lang content attribute.

3.4.4. The dir attribute

The dir attribute specifies the element's text directionality. The attribute is an enumerated attribute with the keyword ltr mapping to the state ltr, and the keyword rtl mapping to the state rtl. The attribute has no defaults.

If the attribute has the state ltr, the element's directionality is left-to-right. If the attribute has the state rtl, the element's directionality is right-to-left. Otherwise, the element's directionality is the same as its parent.

The processing of this attribute depends on the presentation layer. For example, CSS 2.1 defines a mapping from this attribute to the CSS 'direction' and 'unicode-bidi' properties, and defines rendering in terms of those properties.

The dir DOM attribute on an element must reflect the dir content attribute of that element, limited to only known values.

The dir DOM attribute on HTMLDocument objects must reflect the dir content attribute of the html element, if any, limited to only known values. If there is no such element, then the attribute must return the empty string and do nothing on setting.

3.4.5. The class attribute

Every HTML element may have a class attribute specified.

The attribute, if specified, must have a value that is an unordered set of space-separated tokens representing the various classes that the element belongs to.

The classes that an HTML element has assigned to it consists of all the classes returned when the value of the class attribute is split on spaces.

Assigning classes to an element affects class matching in selectors in CSS, the getElementsByClassName() method in the DOM, and other such features.

Authors may use any value in the class attribute, but are encouraged to use the values that describe the nature of the content, rather than values that describe the desired presentation of the content.

The className and classList DOM attributes must both reflect the class content attribute.

3.4.6. The irrelevant attribute

All elements may have the irrelevant content attribute set. The irrelevant attribute is a boolean attribute. When specified on an element, it indicates that the element is not yet, or is no longer, relevant. User agents should not render elements that have the irrelevant attribute specified.

In the following skeletal example, the attribute is used to hide the Web game's main screen until the user logs in:

  <h1>The Example Game</h1>
  <section id="login">
   <h2>Login</h2>
   <form>
    ...
    <!-- calls login() once the user's credentials have been checked -->
   </form>
   <script>
    function login() {
      // switch screens
      document.getElementById('login').irrelevant = true;
      document.getElementById('game').irrelevant = false;
    }
   </script>
  </section>
  <section id="game" irrelevant>
   ...
  </section>

The irrelevant attribute must not be used to hide content that could legitimately be shown in another presentation. For example, it is incorrect to use irrelevant to hide panels in a tabbed dialog, because the tabbed interface is merely a kind of overflow presentation — showing all the form controls in one big page with a scrollbar would be equivalent, and no less correct.

Elements in a section hidden by the irrelevant attribute are still active, e.g. scripts and form controls in such sections still render execute and submit respectively. Only their presentation to the user changes.

The irrelevant DOM attribute must reflect the content attribute of the same name.