The attribute index of the HTML Living Standard, in three tables: the attributes every element takes, those of particular elements, and the event handler attributes, followed by the enumerated values. Values are strings; the types and rules are given per attribute. Attribute syntax is on the syntax page.
Global attributes
These can be used on any HTML element (and class, id,
style, tabindex and nonce on SVG and MathML
elements too). Attributes starting data- are for scripts, those starting
aria- are WAI-ARIA states and properties.
| Attribute | Meaning | Value |
|---|---|---|
accesskey | Keyboard shortcut to focus or activate | Unique space-separated single characters |
autocapitalize | How typed text is capitalised | off, none, on, sentences, words, characters |
autocorrect | Whether typed text is corrected | on, off, or empty |
autofocus | Focus when the page loads | Boolean |
class | Classes the element belongs to | Space-separated tokens |
contenteditable | Whether the user can edit it | true, false, plaintext-only, or empty (true) |
dir | Text direction | ltr, rtl, auto |
draggable | Whether it can be dragged | true, false |
enterkeyhint | What Enter does on a virtual keyboard | enter, done, go, next, previous, search, send |
headingoffset | Offsets heading levels inside it | Integer 0 to 8 |
headingreset | Stops a heading offset passing through | Boolean |
hidden | Not relevant yet | hidden, until-found, or empty |
id | A unique identifier | Text with no white space |
inert | Makes it unfocusable and ignored by assistive technology | Boolean |
inputmode | Which virtual keyboard to show | none, text, tel, email, url, numeric, decimal, search |
is | Creates a customised built-in element | A custom element name |
itemid | Microdata: global identifier of the item | URL |
itemprop | Microdata: property names | Space-separated tokens |
itemref | Microdata: other elements belonging to the item | Space-separated IDs |
itemscope | Microdata: starts an item | Boolean |
itemtype | Microdata: item types | Space-separated absolute URLs |
lang | The language of the content | BCP 47 language tag, or empty |
nonce | Nonce for Content Security Policy | Text |
popover | Makes it a popover | auto, manual, hint, or empty (auto) |
slot | The shadow tree slot it goes into | Text |
spellcheck | Whether spelling is checked | true, false, or empty |
style | Inline CSS | CSS declarations |
tabindex | Whether and in what order it takes focus | Integer |
title | Advisory text, usually a tooltip | Text |
translate | Whether it is translated | yes, no, or empty |
writingsuggestions | Whether writing suggestions are offered | true, false, or empty |
Attributes of particular elements
| Attribute | Elements | Meaning | Value |
|---|---|---|---|
abbr | th | Short label for the header cell | Text |
accept | input | File types accepted | Comma-separated MIME types or extensions |
accept-charset | form | Encodings for submission | UTF-8 (case-insensitive) |
action | form | Where the form is sent | URL |
allow | iframe | Permissions Policy for the frame | Serialised policy |
allowfullscreen | iframe | Allow fullscreen | Boolean |
alpha | input | Allow a colour’s alpha to be set | Boolean |
alt | area, img, input | Replacement text | Text |
as | link | What a preload is for | see values |
async | script | Run as soon as it arrives | Boolean |
autocomplete | form, input, select, textarea | Autofill setting or hint | on or off on a form; field names and tokens on a control |
autoplay | audio, video | Start playing when it can | Boolean |
blocking | link, script, style | What it blocks until loaded | render |
charset | meta | The encoding | utf-8 |
checked | input | Starts checked | Boolean |
cite | blockquote, del, ins, q | Source of the quotation or change | URL |
closedby | dialog | How it can be closed | any, closerequest, none |
color | link | Colour for a site icon | CSS colour |
colorspace | input | Colour space of the value | limited-srgb, display-p3 |
cols | textarea | Width in characters | Positive integer |
colspan | td, th | Columns the cell spans | Positive integer |
command | button | Action to request of the target | show-modal, close, request-close, toggle-popover, show-popover, hide-popover, or a custom command starting with -- |
commandfor | button | The element to act on | ID |
content | meta | The metadata value | Text |
controls | audio, video, img | Show the user agent’s controls | Boolean |
coords | area | Coordinates of the shape | List of numbers |
crossorigin | audio, img, link, script, video | CORS mode for fetches | anonymous, use-credentials, or empty |
data | object | Address of the resource | URL |
datetime | del, ins, time | When it happened, or a machine-readable date | Date and time strings |
decoding | img | How to decode | sync, async, auto |
default | track | Use this track when nothing better fits | Boolean |
defer | script | Run after parsing | Boolean |
dirname | input, textarea | Form field for the text direction | Text |
disabled | button, fieldset, input, link, optgroup, option, select, textarea | Disabled | Boolean |
download | a, area | Download and name the file | Text |
enctype | form | Encoding of the form data | application/x-www-form-urlencoded, multipart/form-data, text/plain |
fetchpriority | img, link, script | Fetch priority | auto, high, low |
for | label, output, template | The control labelled, source controls, or what to update | ID, IDs, or text |
form | button, fieldset, input, object, output, select, textarea | Associates with a form | ID |
formaction, formenctype, formmethod, formnovalidate, formtarget | button, input | Override the form’s submission settings | As their form attributes |
headers | td, th | The header cells for this cell | Space-separated IDs |
height, width | canvas, embed, iframe, img, input, object, source, video | Dimensions | Non-negative integer |
high, low, optimum | meter | Ends of the high and low ranges, and the best value | Number |
href | a, area, base, link | Address of the link, or base URL | URL |
hreflang | a, link | Language of the linked resource | Language tag |
http-equiv | meta | Pragma directive | see values |
imagesizes, imagesrcset | link | Image details for a preload | Source sizes and candidates |
integrity | link, script | Subresource Integrity hash | Text |
ismap | img | Server-side image map | Boolean |
kind | track | Kind of text track | subtitles, captions, descriptions, chapters, metadata |
label | optgroup, option, track | Text shown to the user | Text |
list | input | A datalist of suggestions | ID |
loading | audio, iframe, img, video | When to load | lazy, eager |
loop | audio, video | Play again when finished | Boolean |
max, min | input, meter, progress | Limits of the value | Varies |
maxlength, minlength | input, textarea | Length limits | Non-negative integer |
media | link, meta, source, style | Which media it applies to | Media query list |
method | form | How to send the form | get, post, dialog |
multiple | input, select | Allow several values | Boolean |
muted | audio, video | Start muted | Boolean |
name | button, details, fieldset, form, iframe, input, map, meta, object, output, select, slot, textarea | Name, whose purpose depends on the element | Text |
nomodule | script | Not run in browsers that support modules | Boolean |
novalidate | form | Skip validation | Boolean |
open | details, dialog | Starts open | Boolean |
pattern | input | Regular expression the value must match | JavaScript pattern |
ping | a, area | URLs to ping when followed | Space-separated URLs |
placeholder | input, textarea | Hint when empty | Text |
playsinline | video | Play within the page | Boolean |
popovertarget, popovertargetaction | button, input | The popover to control and how | ID; toggle, show, hide |
poster | video | Image before playback | URL |
preload | audio, video | How much to buffer | none, metadata, auto, or empty |
readonly | input, textarea | Read only | Boolean |
referrerpolicy | a, area, iframe, img, link, script | What referrer to send | see values |
rel | a, area, form, link | Relationship to the linked resource | see values |
required | input, select, textarea | Must be filled in | Boolean |
reversed | ol | Numbered in reverse | Boolean |
rows | textarea | Height in lines | Positive integer |
rowspan | td, th | Rows the cell spans | Non-negative integer |
sandbox | iframe | Restrictions on the frame | see values |
scope | th | The cells it heads | row, col, rowgroup, colgroup |
selected | option | Starts selected | Boolean |
shadowrootmode, shadowrootslotassignment, shadowrootdelegatesfocus, shadowrootserializable, shadowrootclonable, shadowrootcustomelementregistry | template | Declare and configure a shadow root | open, closed; named, manual; Booleans |
shape | area | The shape | circle, default, poly, rect |
size | input, select | Size of the control | Positive integer |
sizes | img, link, source | Display sizes, or icon sizes on link | Source sizes; on link, sizes such as 32x32 or any |
span | col, colgroup | How many columns | Positive integer |
src | audio, embed, iframe, img, input, script, source, track, video | Address of the resource | URL |
srcdoc | iframe | An inline document | HTML source |
srclang | track | Language of the track | Language tag |
srcset | img, source | Image candidates | Image candidate strings |
start | ol | Number of the first item | Integer |
step | input | Granularity of the value | Number, or any |
target | a, area, base, form | Where to open or show the result | _blank, _self, _parent, _top, or a browsing context name |
type | a, button, embed, input, link, object, ol, script, source | Depends on the element | see values |
usemap | img | An image map to use | Hash-name reference |
value | button, data, input, li, meter, option, progress | The element’s value | Varies |
wrap | textarea | How lines wrap when submitted | soft, hard |
Event handler attributes
Each runs its value as script when the event fires. On any element:
onauxclick, onbeforeinput, onbeforematch,
onbeforetoggle, onblur, oncancel,
oncanplay, oncanplaythrough, onchange,
onclick, onclose, oncommand,
oncontextlost, oncontextmenu, oncontextrestored,
oncopy, oncuechange, oncut, ondblclick,
ondrag, ondragend, ondragenter,
ondragleave, ondragover, ondragstart,
ondrop, ondurationchange, onemptied,
onended, onerror, onfocus,
onformdata, oninput, oninvalid,
onkeydown, onkeypress, onkeyup,
onload, onloadeddata, onloadedmetadata,
onloadstart, onmousedown, onmouseenter,
onmouseleave, onmousemove, onmouseout,
onmouseover, onmouseup, onpaste,
onpause, onplay, onplaying,
onprogress, onratechange, onreset,
onresize, onscroll, onscrollend,
onsecuritypolicyviolation, onseeked, onseeking,
onselect, onslotchange, onstalled,
onsubmit, onsuspend, ontimeupdate,
ontoggle, onvolumechange, onwaiting,
onwheel.
On body, for events of the Window: onafterprint,
onbeforeprint, onbeforeunload, onhashchange,
onlanguagechange, onmessage, onmessageerror,
onoffline, ononline, onpagehide,
onpagereveal, onpageshow, onpageswap,
onpopstate, onrejectionhandled, onstorage,
onunhandledrejection, onunload.
Enumerated values
input types
| Value | Control |
|---|---|
text | One line of text (the default) |
search | A search field |
tel | A telephone number |
url | A web address |
email | An email address |
password | Masked text |
date, month, week, time, datetime-local | Date and time controls |
number | A number |
range | A slider |
color | A colour |
checkbox, radio | A checkbox, a radio button |
file | A file picker |
submit, image, reset, button | Buttons |
hidden | Not displayed |
Link relations, the rel attribute
| Value | Meaning |
|---|---|
alternate | Another version of the document |
author | Information about the author |
bookmark | A permalink (a, area) |
canonical | The preferred URL |
dns-prefetch | Look up the host early |
expect | Hold rendering until an element arrives |
external | A site outside this one |
help | Help for this page |
icon | The page’s icon |
license | The licence |
manifest | The web app manifest |
me | Another address of the page’s owner |
modulepreload | Fetch a module early |
next, prev | The next or previous document in a series |
nofollow | Do not count this link for ranking |
noopener, noreferrer, opener | Control what the new page can reach and what referrer is sent |
pingback | The pingback server |
preconnect, prefetch, preload, prerender | Resource hints: connect, fetch, load or render ahead of time |
privacy-policy, terms-of-service | The privacy policy, the terms |
search | A search interface |
stylesheet | A CSS style sheet |
tag | A tag for this page (a, area) |
meta names and pragmas
| Attribute and value | Meaning |
|---|---|
name="application-name" | The web application’s name |
name="author" | The author |
name="description" | A summary of the page |
name="generator" | The software that made the page |
name="keywords" | Keywords |
name="referrer" | The default referrer policy |
name="theme-color" | A colour for the browser’s interface |
name="color-scheme" | Colour schemes supported |
name="viewport" | Layout hints for small screens (CSS Viewport) |
name="robots" | Directions for search engines (registered extension) |
http-equiv="content-type" | Declares the encoding |
http-equiv="default-style" | The preferred style sheet set |
http-equiv="refresh" | Reload or redirect after a delay |
http-equiv="x-ua-compatible" | Old Internet Explorer compatibility; only IE=edge conforms |
http-equiv="content-security-policy" | A Content Security Policy |
Other keyword sets
| Attribute | Values |
|---|---|
as (link) | fetch, audio, document, embed, font, image, object, script, style, track, video, worker |
referrerpolicy | no-referrer, no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin (the default), unsafe-url |
sandbox (iframe) | allow-downloads, allow-forms, allow-modals, allow-orientation-lock, allow-pointer-lock, allow-popups, allow-popups-to-escape-sandbox, allow-presentation, allow-same-origin, allow-scripts, allow-top-navigation, allow-top-navigation-by-user-activation, allow-top-navigation-to-custom-protocols |
type (button) | submit, reset, button |
type (ol) | 1, a, A, i, I |
type (script) | module, importmap, speculationrules; absent or a JavaScript MIME type is a classic script; any other value is a data block |