Global HTML Attributes in HTML

From the HTML cheat sheet ยท Accessibility ยท verified Jul 2026

Global HTML Attributes

Common attributes that work on any HTML element

html
<div id="unique-id">Unique identifier</div>
<div class="card highlighted">CSS classes</div>
<div data-user-id="123" data-role="admin">Custom data</div>
<div hidden>Not displayed</div>
<div contenteditable="true">Editable text</div>
<div draggable="true">Drag me</div>
๐Ÿ’ก data-* attributes store custom data on elements โ€” access via element.dataset in JavaScript
โšก Use hidden instead of CSS display:none when you want to toggle visibility with JS
๐Ÿ“Œ tabindex="0" makes any element focusable; tabindex="-1" makes it programmatically focusable only
๐ŸŸข The lang attribute helps screen readers pronounce content correctly โ€” set it on <html> at minimum
attributesdataglobal

More HTML tasks

Back to the full HTML cheat sheet