| Quick Reference HTML CheatsheetComplete HTML5 tag and attribute reference — global attributes, every common element’s attributes, and colorized code snippets for fast revision. Global Attributes (most elements)These attributes can appear on nearly every HTML element.
Document Structure TagsColorized skeleton
Head / Metadata Tags & Attributes
Common
Sectioning / Landmark Tags
Text / Content Block Tags
Inline / Phrase Tags & Attributes
Links — |
| Attribute | Values / notes |
|---|---|
href | URL, #id, mailto:, tel:, javascript: (avoid) |
target | _self | _blank | _parent | _top | framename |
rel | e.g. noopener, noreferrer, nofollow, sponsored, ugc, alternate |
download | Boolean or filename for downloadable resource |
hreflang | Language of linked document |
type | MIME type hint of linked resource |
ping | Space-separated tracking URLs |
referrerpolicy | Referrer policy for the navigation |
ping / media attrs | — |
| global | id, class, title, ARIA, … |
Media & Embed Tags — Full Attributes
<img
src="/hero.webp"
srcset="/hero-400.webp 400w, /hero-800.webp 800w"
sizes="(max-width: 600px) 100vw, 800px"
alt="Students coding in a lab"
width="800"
height="450"
loading="lazy"
decoding="async"
fetchpriority="high"
/>
<video controls poster="/p.jpg" width="640"
preload="metadata" playsinline>
<source src="/v.webm" type="video/webm" />
<track kind="captions" srclang="en" src="/c.vtt" label="English" default />
</video> | Tag | Attributes |
|---|---|
img | alt, src, srcset, sizes, width, height,
loading (lazy|eager), decoding (async|sync|auto),
crossorigin, ismap, usemap, referrerpolicy,
fetchpriority, elementtiming, attributionsrc, global
|
picture | global — wraps source + img |
source | src, type, srcset, sizes, media,
width, height, global
|
video | src, controls, autoplay, loop, muted,
playsinline, poster, preload (none|metadata|auto),
width, height, crossorigin, disablepictureinpicture,
disableremoteplayback, controlslist, global
|
audio | src, controls, autoplay, loop, muted,
preload, crossorigin, controlslist,
disableremoteplayback, global
|
track | kind (subtitles|captions|descriptions|chapters|metadata),
src, srclang, label, default, global
|
iframe | src, srcdoc, name, width, height,
allow, allowfullscreen, loading, referrerpolicy,
sandbox, csp, credentialless, global
|
embed | src, type, width, height, global |
object | data, type, name, form, width,
height, usemap, typemustmatch, global
|
param | name, value, global — child of object |
map | name, global |
area | alt, coords, shape (rect|circle|poly|default),
href, target, download, ping, rel,
referrerpolicy, global
|
canvas | width, height, global |
svg | SVG attrs (viewBox, xmlns, width, height, …) |
List Tags & Attributes
<ol type="1" start="3" reversed>
<li value="3">Third</li>
</ol>
<ul>
<li>Item</li>
</ul>
<dl>
<dt>HTML</dt>
<dd>Structure</dd>
</dl> | Tag | Attributes |
|---|---|
ul | global |
ol | reversed, start, type (1|a|A|i|I), global |
li | value (in ol), global |
dl | global |
dt | global |
dd | global |
menu | global (toolbar / context list semantics vary) |
Table Tags & Attributes
<table>
<caption>Scores</caption>
<colgroup>
<col span="2" />
</colgroup>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Marks</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Ada</th>
<td colspan="1">95</td>
</tr>
</tbody>
</table> | Tag | Attributes |
|---|---|
table | global (avoid legacy border/width — use CSS) |
caption | global |
colgroup | span, global |
col | span, global |
thead / tbody / tfoot | global |
tr | global |
th | abbr, colspan, rowspan,
headers, scope (row|col|rowgroup|colgroup), global
|
td | colspan, rowspan, headers, global |
Forms — Tags & Every Key Attribute
<form
action="/subscribe"
method="post"
enctype="multipart/form-data"
autocomplete="on"
novalidate
>
<label for="email">Email</label>
<input
id="email"
name="email"
type="email"
required
placeholder="you@example.com"
autocomplete="email"
inputmode="email"
maxlength="120"
/>
<button type="submit">Send</button>
</form> <form>
| Attribute | Values / notes |
|---|---|
action | Submission URL |
method | get | post | dialog |
enctype | application/x-www-form-urlencoded | multipart/form-data | text/plain |
autocomplete | on | off |
name | Form name |
novalidate | Skip built-in validation |
target | Where to display response |
rel | Link relationship for submission |
accept-charset | Character encodings |
<input> — type values
| type | type | type | type |
|---|---|---|---|
button | checkbox | color | date |
datetime-local | email | file | hidden |
image | month | number | password |
radio | range | reset | search |
submit | tel | text | time |
url | week |
<input> attributes (by group)
| Group | Attributes |
|---|---|
| Identity | name, id, type, value, form |
| Validation | required, pattern, min, max,
minlength, maxlength, step, multiple |
| UI / UX | placeholder, readonly, disabled, size,
autocomplete, autofocus, list, dirname,
inputmode, enterkeyhint |
| File / image | accept, capture, src, alt,
width, height, formaction, formenctype,
formmethod, formnovalidate, formtarget |
| Checked controls | checked, indeterminate (JS) |
| Misc | popovertarget, popovertargetaction, global |
| Tag | Attributes |
|---|---|
label | for, global |
textarea | name, rows, cols, wrap (soft|hard),
maxlength, minlength, placeholder, readonly,
required, disabled, autocomplete, dirname,
form, autofocus, global
|
select | name, multiple, size, required,
disabled, autofocus, autocomplete, form, global
|
optgroup | label, disabled, global |
option | value, label, selected, disabled, global |
button | type (submit|reset|button), name, value,
disabled, form, formaction, formenctype,
formmethod, formnovalidate, formtarget,
popovertarget, popovertargetaction, global
|
fieldset | disabled, form, name, global |
legend | global |
datalist | global — options for list |
output | for, form, name, global |
progress | value, max, global |
meter | value, min, max, low, high, optimum, global |
Interactive / Disclosure Tags
<details open name="faq">
<summary>What is HTML?</summary>
<p>Markup language for documents.</p>
</details>
<dialog open>…</dialog> | Tag | Attributes |
|---|---|
details | open, name (exclusive accordion group), global |
summary | global |
dialog | open, global |
template | shadowrootmode, shadowrootdelegatesfocus, global |
slot | name, global |
Script, Style & Template Attributes
<script type="module" src="/app.js" defer></script>
<script nomodule src="/legacy.js"></script>
<noscript>Enable JavaScript for the interactive demo.</noscript> | Tag | Attributes |
|---|---|
script | src, type, async, defer, crossorigin,
integrity, nomodule, nonce, referrerpolicy,
fetchpriority, blocking, attributionsrc, global
|
noscript | global |
style | media, nonce, title, blocking, global |
Gotchas & Interview Tips
- Boolean attributes are present/absent — write
required, notrequired="false". - Void elements have no end tag:
img,br,hr,input,meta,link,source,track,area,col,wbr,embed,param,base. - Always pair
labelwith controls viafor/idor wrapping. - Use
rel="noopener noreferrer"withtarget="_blank". - Prefer semantic tags over
div/spansoup; add ARIA only when native semantics are insufficient. - Global attributes (especially
id,class,hidden,tabindex,aria-*) apply across nearly every tag above.
Next: HTML tutorial · Cheatsheet hub