--- title: Global attributes slug: Web/HTML/Global_attributes tags: - Attribute - HTML - NeedsTranslation - Reference - TopicStub - Web translation_of: Web/HTML/Global_attributes ---
Global attributes are attributes common to all HTML elements; they can be used on all elements, though they may have no effect on some elements.
Global attributes may be specified on all HTML elements, even those not specified in the standard. That means that any non-standard elements must still permit these attributes, even though using those elements means that the document is no longer HTML5-compliant. For example, HTML5-compliant browsers hide content marked as <foo hidden>...</foo>, even though <foo> is not a valid HTML element.
In addition to the basic HTML global attributes, the following global attributes also exist:
aria-* attributes, used for improving accessibility.onabort, onautocomplete, onautocompleteerror, onblur, oncancel, oncanplay, oncanplaythrough, onchange, onclick, onclose, oncontextmenu, oncuechange, ondblclick, ondrag, ondragend, ondragenter, ondragexit, ondragleave, ondragover, ondragstart, ondrop, ondurationchange, onemptied, onended, onerror, onfocus, oninput, oninvalid, onkeydown, onkeypress, onkeyup, onload, onloadeddata, onloadedmetadata, onloadstart, onmousedown, onmouseenter, onmouseleave, onmousemove, onmouseout, onmouseover, onmouseup, onmousewheel, onpause, onplay, onplaying, onprogress, onratechange, onreset, onresize, onscroll, onseeked, onseeking, onselect, onshow, onsort, onstalled, onsubmit, onsuspend, ontimeupdate, ontoggle, onvolumechange, onwaiting.off or none, no autocapitalization is applied (all letters default to lowercase)on or sentences, the first letter of each sentence defaults to a capital letter; all other letters default to lowercasewords, the first letter of each word defaults to a capital letter; all other letters default to lowercasecharacters, all letters should default to uppercasetrue or the empty string, which indicates that the element must be editable;false, which indicates that the element must not be editable.id of a {{HTMLElement("menu")}} to use as the contextual menu for this element.ltr, which means left to right and is to be used for languages that are written from the left to the right (like English);rtl, which means right to left and is to be used for languages that are written from the right to the left (like Arabic);auto, which lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then it applies that directionality to the whole element.true, which indicates that the element may be draggedfalse, which indicates that the element may not be dragged.copy, which indicates that dropping will create a copy of the element that was draggedmove, which indicates that the element that was dragged will be moved to this new location.link, will create a link to the dragged data.Note: The item* attributes are part of the WHATWG HTML Microdata feature.
itemprop attribute specified, where an itemprop consists of a name and value pair.itemscope attribute can be associated with the item using an itemref. It provides a list of element ids (not itemids) with additional properties elsewhere in the document.itemscope (usually) works along with {{HTMLAttrxRef("itemtype")}} to specify that the HTML contained in a block is about a particular item. itemscope creates the Item and defines the scope of the itemtype associated with it. itemtype is a valid URL of a vocabulary (such as schema.org) that describes the item and its properties context.itemprops (item properties) in the data structure. {{HTMLAttrxRef("itemscope")}} is used to set the scope of where in the data structure the vocabulary set by itemtype will be active.slot attribute is assigned to the slot created by the {{HTMLElement("slot")}} element whose {{HTMLAttrxRef("name", "slot")}} attribute's value matches that slot attribute's value.true, which indicates that the element should be, if possible, checked for spelling errors;false, which indicates that the element should not be checked for spelling errors.0 means that the element should be focusable and reachable via sequential keyboard navigation, but its relative order is defined by the platform convention;yes, which indicates that the element will be translated.no, which indicates that the element will not be translated.| Specification | Status | Comment |
|---|---|---|
| {{SpecName("HTML WHATWG", "dom.html#global-attributes", "Global attributes")}} | {{Spec2("HTML WHATWG")}} | |
| {{SpecName("CSS Shadow Parts", "#exposing")}} | {{Spec2("CSS Shadow Parts")}} | Added the part and exportparts global attributes. |
| {{SpecName("HTML5.2", "dom.html#global-attributes", "Global attributes")}} | {{Spec2("HTML5.2")}} | Snapshot of {{SpecName("HTML WHATWG")}}. From {{SpecName("HTML5.1")}}, itemid, itemprop, itemref, itemscope, and itemtype have been added. |
| {{SpecName("HTML5.1", "dom.html#global-attributes", "Global attributes")}} | {{Spec2("HTML5.1")}} | Snapshot of {{SpecName("HTML WHATWG")}}. From {{SpecName("HTML5 W3C")}}, contextmenu, draggable, dropzone, and spellcheck have been added. |
| {{SpecName("HTML5 W3C", "dom.html#global-attributes", "Global attributes")}} | {{Spec2("HTML5 W3C")}} | Snapshot of {{SpecName("HTML WHATWG")}}. From {{SpecName("HTML4.01")}}, the concept of global attributes is introduced and the dir, lang, style, id, class, tabindex, accesskey, and title are now true global attributes.xml:lang which was initially part of XHTML, is now also part of HTML.hidden, data-*, contenteditable, and translate have been added. |
| {{SpecName("HTML4.01")}} | {{Spec2("HTML4.01")}} | There are no global attributes defined. Several attributes that will become global attributes in subsequent specifications are defined on a subset of elements.class and style are supported on all elements but {{HTMLElement("base")}}, {{HTMLElement("basefont")}}, {{HTMLElement("head")}}, {{HTMLElement("html")}}, {{HTMLElement("meta")}}, {{HTMLElement("param")}}, {{HTMLElement("script")}}, {{HTMLElement("style")}}, and {{HTMLElement("title")}}.dir is supported on all elements but {{HTMLElement("applet")}}, {{HTMLElement("base")}}, {{HTMLElement("basefont")}}, {{HTMLElement("bdo")}}, {{HTMLElement("br")}}, {{HTMLElement("frame")}}, {{HTMLElement("frameset")}}, {{HTMLElement("iframe")}}, {{HTMLElement("param")}}, and {{HTMLElement("script")}}.id is supported on all elements but {{HTMLElement("base")}}, {{HTMLElement("head")}}, {{HTMLElement("html")}}, {{HTMLElement("meta")}}, {{HTMLElement("script")}}, {{HTMLElement("style")}}, and {{HTMLElement("title")}}.lang is supported on all elements but {{HTMLElement("applet")}}, {{HTMLElement("base")}}, {{HTMLElement("basefont")}}, {{HTMLElement("br")}}, {{HTMLElement("frame")}}, {{HTMLElement("frameset")}}, {{HTMLElement("iframe")}}, {{HTMLElement("param")}}, and {{HTMLElement("script")}}.tabindex is only supported on {{HTMLElement("a")}}, {{HTMLElement("area")}}, {{HTMLElement("button")}}, {{HTMLElement("object")}}, {{HTMLElement("select")}}, and {{HTMLElement("textarea")}}.accesskey is only supported on {{HTMLElement("a")}}, {{HTMLElement("area")}}, {{HTMLElement("button")}}, {{HTMLElement("input")}}, {{HTMLElement("label")}}, {{HTMLElement("legend")}} and {{HTMLElement("textarea")}}.title is supported on all elements but {{HTMLElement("base")}}, {{HTMLElement("basefont")}}, {{HTMLElement("head")}}, {{HTMLElement("html")}}, {{HTMLElement("meta")}}, {{HTMLElement("param")}}, {{HTMLElement("script")}}, and {{HTMLElement("title")}}. |
{{Compat("html.global_attributes")}}