Global Attributes

Disclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page. Learn more

Most HTML attributes are specified to be used with particular elements. However, several attributes are available for use on all HTML elements. These are called global attributes.

accesskey
Defines a shortcut key which can be used to select or activate the element.
<p><a href="/" title="Home" accesskey="h">This link to the home page has an `accesskey` value of `h`.</a> </p>
Press <kbd>alt</kbd> + <kbd>H</kbd> (<kbd>control</kbd> + <kbd>alt</kbd> + <kbd>H</kbd> on Mac) to go home.
This link to the home page has an `accesskey` value of `h`.
Press alt + H (control + alt + H on Mac) to go home.
class
Specifies one or more classes to which the element belongs. Classes are often used as selectors for CSS rules and JavaScript functions.
contenteditable
Specifies whether or not the content of the element is editable.
New in HTML5.
contextmenu
Identies a <menu> element which is to be used as a contextual menu (right-click menu) for the element.
New in HTML5.
Not implemented in most browsers.
data-*
Defines an element-specific data-store which can be accessed by JavaScript.
New in HTML5.
dir
Specifies the text direction (rtl or ltr) for the content inside the element
draggable
Specifies whether or not an element can be moved (click-and-drag) by the user.
New in HTML5.
dropzone
Specifies how data from a dragged element is treated when dropped.
New in HTML5.
Not implemented in most browsers.
hidden
Hides an element from view.
New in HTML5.
id
Defines a unique id for an element. IDs are often used as selectors for CSS and JavaScript, and can also be linked to in a URL (example.com/page#element-id).
lang
Identifies the language of the element’s content.
spellcheck
Specifies whether the browser should check the spelling and grammar of the element’s content.
New in HTML5.
style
Contains inline CSS styles for the element.
Not usually recommended. (Use an external stylesheet or, if needed, the <style> element.)
tabindex
Specifies the order in which elements will come into focus when the page is tabbed through.
title
Specifies a title, name, or arbitrary information about the element. The title is usually displayed as a tool-tip when the user hovers over the element.
translate
Specifies whether or not the element’s contents should be translated.
New in HTML5.
Not implemented in most browsers. (May be implemented in translation tools and plugins.)
Adam is a technical writer who specializes in developer documentation and tutorials.