Attribute Reference
A scannable index of the HTML attributes you'll use most often—global attributes available on every element, plus the specialized ones for forms, media, links, and accessibility.
Global Attributes
These work on virtually every HTML element.
Attribute | Description |
|---|---|
id | A unique identifier for the element within the document |
class | One or more space-separated CSS class names |
style | Inline CSS declarations, applied only to this element |
title | Advisory text, usually shown as a tooltip on hover |
lang | The natural language of the element's content |
dir | Text direction: ltr, rtl, or auto |
hidden | Removes the element from rendering and the accessibility tree |
tabindex | Adds the element to (or removes it from) the keyboard tab order |
contenteditable | Makes the element directly editable by the user |
draggable | Enables the element to be dragged via the Drag and Drop API |
spellcheck | Suggests whether the browser should spell-check the element's text |
data-* | Custom attributes for storing element-specific data for scripting |
accesskey | A single-key keyboard shortcut to focus/activate the element |
translate | Hints to translation tools whether content should be translated |
Form Attributes
Attribute | Applies to | Description |
|---|---|---|
action | <form> | The URL the form data is submitted to |
method | <form> | HTTP method for submission: get or post |
enctype | <form> | Encoding for the submitted data, e.g. multipart/form-data for file uploads |
novalidate | <form> | Disables native browser validation on submit |
name | form controls | The key used when submitting this field's value |
value | form controls | The control's current or default value |
type | <input>, <button> | Selects the specific control variant |
placeholder | text-like inputs | Faint hint text shown when the field is empty |
required | form controls | Marks the field as mandatory for submission |
disabled | form controls | Disables the control and excludes it from submission |
readonly | text-like inputs | Prevents editing but still submits the field's value |
checked | checkbox, radio | Marks a checkbox/radio as initially selected |
multiple | file, select, email | Allows selecting/entering more than one value |
min / max / step | number, range, date-like inputs | Bounds and increment for numeric/date inputs |
pattern | text-like inputs | A regular expression the value must match |
minlength / maxlength | text-like inputs | Minimum/maximum character count allowed |
autocomplete | form, form controls | Hints the browser on autofill behavior |
autofocus | one form control per page | Focuses the element automatically on page load |
for | <label> | Associates the label with a control by matching id |
form | form controls | Associates a control with a <form> elsewhere in the document |
Media Attributes
Attribute | Applies to | Description |
|---|---|---|
src | img, video, audio, iframe, script | The URL of the embedded resource |
alt | img, area | Alternative text describing the image's content |
width / height | img, video, iframe, canvas | Intrinsic dimensions; reserves layout space |
loading | img, iframe | lazy defers off-screen loading; eager loads immediately |
srcset | img, source | A set of image candidates at different resolutions/widths |
sizes | img, source | Hints the rendered width of the image at various viewport sizes |
controls | audio, video | Shows the browser's native playback UI |
autoplay | audio, video | Starts playback automatically (often requires muted) |
loop | audio, video | Restarts playback automatically when it ends |
muted | audio, video | Mutes audio output by default |
poster | video | An image shown before playback starts |
preload | audio, video | Hints how much to buffer before playback: none, metadata, auto |
fetchpriority | img, link, script | Hints the relative fetch priority of the resource |
decoding | img | Hints whether image decoding may happen async or must be sync |
Link Attributes
Attribute | Applies to | Description |
|---|---|---|
href | a, link, area, base | The destination URL |
target | a, form, iframe | Where to open the result: _blank, _self, _parent, _top |
rel | a, link | Relationship between the current document and the target (e.g. nofollow, noopener) |
download | a | Forces the browser to download the link's target instead of navigating |
hreflang | a, link | The language of the linked resource |
type | link, script, a | The MIME type of the linked/embedded resource |
as | link (rel=preload) | The kind of resource being preloaded, for correct prioritization |
crossorigin | link, script, img | Configures CORS behavior for the fetch |
integrity | link, script | A subresource-integrity hash to verify fetched content |
referrerpolicy | a, link, img, iframe | Controls how much referrer information is sent |
ARIA Attributes Overview
ARIA (Accessible Rich Internet Applications) attributes supplement native HTML semantics for assistive technology. Prefer native elements first—reach for ARIA only when no native element covers the interaction.
Attribute | Description |
|---|---|
role | Declares or overrides an element's accessibility role |
aria-label | Supplies an accessible name when no visible text label exists |
aria-labelledby | Points to another element (by id) that provides the accessible name |
aria-describedby | Points to element(s) supplying additional descriptive text |
aria-hidden | Hides an element (and its descendants) from the accessibility tree |
aria-live | Marks a region whose content changes should be announced automatically |
aria-expanded | Indicates whether a collapsible control is currently expanded |
aria-checked | Indicates the checked state of a custom checkbox/radio/switch |
aria-disabled | Indicates the element is perceivable but currently disabled |
aria-invalid | Flags a form field as currently failing validation |
aria-current | Marks the current item within a set (e.g. current page in nav) |
aria-controls | Identifies the element(s) whose content this control affects |
aria-haspopup | Indicates the element triggers a popup (menu, dialog, listbox) |
id, class, and data-* aren't restricted to any specific element—they're valid on virtually all of them, including semantic and form elements listed elsewhere on this page.