HTML Global Attributes

Last updated: 2026-09-12

HTML Global Attributes

Global attributes are attributes that can be used on all HTML elements. They define an element's identity, style, language, and interaction behavior.

Core Identity Attributes

Global AttributesDescription
idA unique identifier for the element, used by CSS selectors, JavaScript and anchor links.
classA space-separated list of class names used by CSS or JavaScript selectors.
styleInline CSS styles applied directly to the element, with higher priority than external stylesheets.
titleTooltip text shown on hover.

Language & Direction

Global AttributesDescription
langDeclares the language of the element's content.
dirText direction: ltr (default) or rtl.

Interaction & Accessibility

Global AttributesDescription
contenteditableSpecifies whether the element's content is editable.
draggableSpecifies whether the element is draggable.
hiddenHides the element from rendering.
tabindexSpecifies the element's tab order.
accesskeyAssigns a keyboard shortcut to focus/activate the element.
spellcheckSpecifies whether the element's content is spell-checked.
translateSpecifies whether the element's content should be translated.
inertMakes the element and its subtree non-interactive.

Data & Others

Global AttributesDescription
data-*Custom data attributes for storing private page/app data.
autofocusAutomatically focuses the element on page load.
autocapitalizeControls auto-capitalization on mobile keyboards.
enterkeyhintHints the label for the virtual keyboard's Enter key.
inputmodeHints the type of virtual keyboard to display.
nonceA cryptographic nonce used by Content Security Policy.
slotAssigns the element to a slot in a shadow DOM.
partNames the element's parts for styling via CSS ::part().
popoverSpecifies the element's popover behavior.
isSpecifies the name of a customized built-in element.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏