What are HTML Global Attributes?
HTML global attributes are universal keywords you can add to any HTML5 element to enhance behavior, accessibility, and styling. Unlike element-specific attributes, these work across all HTML5 tags, giving you consistent control over your markup.
Key Uses of HTML Global Attributes
- Universal enhancement: Apply additional functionality or identifiers to any element, improving structure and maintainability.
- Consistent styling hooks: Enable precise targeting for CSS rules and inline adjustments without extra markup.
- Improved accessibility: Enhance screen reader support and keyboard navigation across all elements.
- Data integration: Pass custom information to scripts for dynamic behavior and rich client-side interactions.
- Content control: Toggle visibility or editability on the fly, streamlining user interface updates.
- Custom element support: Extend these benefits to bespoke or web-component tags while maintaining cross-browser rendering.
Alphabetical Reference of Global Attributes in HTML
Following is the complete, alphabetical list of 33 global attributes in HTML, ready for quick reference and efficient implementation.
Attribute | Description |
accesskey | This global HTML accesskey attribute creates a shortcut key to focus on an element. |
aria-* | The global HTML aria-* attributes allow us to customize the properties and states of a tag. |
autocapitalize | This global HTML autocapitalize attribute sets the input automatically capitalize when entered by the user. |
autofocus | The global HTML autofocus declares the auto focus an element upon loading the page. |
class | This global HTML class attribute defines one or more classes for an element. |
contenteditable | The global HTML contenteditable attribute if this attribute is set to "true" for an element, and the content of the element is editable by the user. |
contextmenu | This global HTML contextmenu attribute defines the ID of a menu element which will serve as the element’s context menu. |
data-* | The global HTML data-* attribute stores the private data of a page or application. |
dir | This global HTML dir attribute declares the direction of the text in an element. |
draggable | The global HTML draggable attribute, if set to "true" for an element, the element is draggable on the screen. |
enterkeyhint | This global HTML enterkeyhint defines a label or icon when some key is pressed on the virtual keyboard. |
exportparts | The global HTML exportparts attribute transitively exports shadow parts from a nested shadow tree into a containing light tree. |
hidden | This global HTML hidden attribute makes an element irrelevant and hides it. |
id | The global HTML id attribute sets the ID for an HTML element. |
inputmode | This global HTML inputmode attribute tells the browser about the type of virtual keyboard configuration to use while editing the current element or its content. This is useful with the <input> tag however we can utilize it with every element with a contenteditable attribute. |
is | The global HTML is attribute enables the specification of a standard HTML element as a custom registered HTML tag. |
itemid | This global HTML itemid acts as a unique global identifier for an element. |
itemprop | The global HTML itemprop attribute adds properties to an element. |
itemref | This global HTML itemref allows us to associate the descendent properties to an element. |
itemscope | The global HTML itemscope attribute works with itemtype and specifies that the HTML contained inside a block relates to a particular item that it creates. |
itemtype | This global HTML itemprop attribute is used to specify the URL vocabulary of the itemprops in the data structure and the scope to become active is set by the itemscope attribute. |
lang | The global HTML lang attribute defines the language of the document. |
nonce | This global HTML nonce attribute sets a cryptographic nonce that is utilized by Content Security Policy(CSP), to check if the current fetch is allowed to proceed further. |
part | The global HTML part attribute creates a space-separated list of names of an element which allows CSS language to select and style specific elements in a shadow tree by employing the ::part pseudo-class. |
role | This global HTML role attribute sets a role for an element while interacting with assistive technologies. |
slot | The global slot HTML attribute assigns a slot in a shadow DOM shadow tree to an element. |
spellcheck | This global HTML spellcheck attribute checks the spellings of text inside an element. |
style | The global HTML style attribute assigns a class to an element. |
tabindex | This global HTML tabindex attribute sets the tabbing order of an element. |
title | The global HTML title attribute provides some extra information to the element that pops up upon hovering on the element. |
translate | This global HTML translate attribute tells the browser whether to translate the content of the element or not. |
xml:lang | The global HTML xml:lang attribute specifies the language of the text enclosed by an element. It is inherited from the XML language. |
xml:base | This global HTML xml:base attribute enables redefining the base address used by relative addresses in the child elements. It is also inherited from the XML language. |
HTML Event Handler Global Attributes
Event handler attributes in HTML are universal and work with any HTML5 element to trigger scripts on user or browser actions. These 72 event attributes let you run JavaScript when events like clicks, input changes, or page loads occur.
Alphabetical Event Handler Reference
Below is a complete alphabetical list of all 72 global event handler attributes in HTML.
- onabort
- onabort
- onafterprint
- onbeforeprint
- onbeforeunload
- onblur
- oncanplay
- oncanplaythrough
- onchange
- onclick
- oncontextmenu
- oncopy
- oncuechange
- oncut
- ondblclick
- ondrag
- ondragend
- ondragenter
- ondragleave
- ondragover
- ondragstart
- ondrop
- ondurationchange
- onemptied
- onended
- onerror
- onfocus
- onhashchange
- oninput
- oninvalid
- onkeydown
- onkeypress
- onkeyup
- onload
- onloadeddata
- onloadedmetadata
- onloadstart
- onmousedown
- onmousemove
- onmouseout
- onmouseover
- onmouseup
- onmousewheel
- onoffline
- ononline
- onpagehide
- onpageshow
- onpaste
- onpause
- onplay
- onplaying
- onpopstate
- onprogress
- onratechange
- onreset
- onresize
- onscroll
- onsearch
- onseeked
- onseeking
- onselect
- onshow
- onstalled
- onstorage
- onsubmit
- onsuspend
- ontimeupdate
- ontoggle
- onunload
- onvolumechange
- onwaiting
- onwheel
HTML Attributes Reference
For a complete overview of all 270+ HTML attributes, visit the HTML5 attribute reference.