Skip to main content
Quick Reference

HTML Cheatsheet

Complete 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.

AttributeValues / notes
accesskeyKeyboard shortcut hint (single character)
autocapitalizeoff | none | on | sentences | words | characters
autofocusBoolean — focus on page load
classSpace-separated CSS classes
contenteditabletrue | false | plaintext-only
data-*Custom data attributes (e.g. data-id="42")
dirltr | rtl | auto
draggabletrue | false
enterkeyhintenter | done | go | next | previous | search | send
hiddenBoolean / until-found — hide from layout
idUnique document identifier
inertBoolean — not interactive / not focusable
inputmodenone | text | decimal | numeric | tel | search | email | url
isCustomized built-in element name
itemid / itemprop / itemref / itemscope / itemtypeMicrodata
langBCP 47 language tag (e.g. en, en-IN)
nonceCSP nonce for inline script/style
partCSS shadow parts export
popoverauto | manual
slotNamed slot assignment
spellchecktrue | false
styleInline CSS
tabindexInteger focus order (0, -1, positive)
titleAdvisory tooltip text
translateyes | no
aria-* / roleAccessibility (ARIA) attributes
on* event handlerse.g. onclick, onload (prefer JS listeners)

Document Structure Tags

Colorized skeleton

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Page Title</title>
</head>
<body>
  <h1>Hello HTML</h1>
</body>
</html>
TagAttributesNotes
!DOCTYPE—Always <!DOCTYPE html> for HTML5
htmllang, dir, xmlns (XHTML), globalRoot element
headglobalMetadata container
bodyglobal (+ legacy presentational attrs avoided)Visible content
noscriptglobalFallback when JS disabled

Head / Metadata Tags & Attributes

<meta charset="UTF-8" />
<meta name="description" content="Short summary" />
<meta http-equiv="refresh" content="30" />
<link rel="stylesheet" href="/styles.css" media="all" />
<base href="https://example.com/" target="_blank" />
<style media="screen" nonce="…">/* CSS */</style>
TagAttributes
titleglobal only — document title text
meta charset; or name + content; or http-equiv + content; property (OG); media; itemprop; global
link href, rel, as, crossorigin, disabled, fetchpriority, hreflang, imagesizes, imagesrcset, integrity, media, referrerpolicy, sizes, title, type, blocking, global
basehref, target, global — one per document
stylemedia, nonce, title, blocking, global
script src, type, async, defer, crossorigin, integrity, nomodule, nonce, referrerpolicy, fetchpriority, blocking, attributionsrc, global

Common meta name values

namecontent purpose
descriptionSEO / snippet summary
viewportMobile layout (width=device-width, initial-scale=1)
robotsindex,follow / noindex …
authorAuthor name
theme-colorBrowser UI color
color-schemelight dark
referrerDefault referrer policy

Sectioning / Landmark Tags

<header class="site-header">…</header>
<nav aria-label="Primary">…</nav>
<main id="content">
  <article itemscope itemtype="https://schema.org/Article">
    <section aria-labelledby="s1">…</section>
  </article>
  <aside>…</aside>
</main>
<footer>…</footer>
TagAttributesMeaning
headerglobalIntro / branding for page or section
navglobal (+ aria-label recommended)Major navigation
mainglobalOne primary content region per page
articleglobal (+ microdata)Self-contained composition
sectionglobalThematic grouping (needs heading)
asideglobalTangentially related content
footerglobalFooter for page or section
addressglobalContact information
hgroupglobalGroups heading + subheading
searchglobalSearch landmark (HTML living standard)

Text / Content Block Tags

TagAttributesUse
h1–h6globalHeadings (outline)
pglobalParagraph
divglobalGeneric block container
hrglobalThematic break (void)
preglobalPreformatted text
blockquotecite, globalLong quotation
figureglobalSelf-contained figure
figcaptionglobalFigure caption
main content helpers—See sectioning

Inline / Phrase Tags & Attributes

<p>
  Use <strong>strong</strong> and <em>em</em>.
  <abbr title="HyperText Markup Language">HTML</abbr>
  <time datetime="2026-11-14">14 Nov 2026</time>
  <data value="42">forty-two</data>
</p>
TagAttributesMeaning
asee LinksHyperlink
abbrtitle (expansion), globalAbbreviation
b / iglobalOffset text (not always strong/em)
bdidir, globalBidirectional isolate
bdodir (required), globalBidirectional override
brglobalLine break (void)
citeglobalTitle of a work
codeglobalCode fragment
datavalue, globalMachine-readable value
dfntitle, globalDefining instance of a term
emglobalStress emphasis
kbdglobalKeyboard input
markglobalHighlighted text
qcite, globalInline quotation
rp / rt / rubyglobalRuby annotations
sglobalStrikethrough / no longer accurate
sampglobalSample output
smallglobalSide comments / fine print
spanglobalGeneric inline
strongglobalStrong importance
sub / supglobalSubscript / superscript
timedatetime, globalDate/time
uglobalUnarticulated annotation
varglobalVariable
wbrglobalWord break opportunity (void)

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>
TagAttributes
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>
TagAttributes
ulglobal
olreversed, start, type (1|a|A|i|I), global
livalue (in ol), global
dlglobal
dtglobal
ddglobal
menuglobal (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>
TagAttributes
tableglobal (avoid legacy border/width — use CSS)
captionglobal
colgroupspan, global
colspan, global
thead / tbody / tfootglobal
trglobal
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>

AttributeValues / notes
actionSubmission URL
methodget | post | dialog
enctypeapplication/x-www-form-urlencoded | multipart/form-data | text/plain
autocompleteon | off
nameForm name
novalidateSkip built-in validation
targetWhere to display response
relLink relationship for submission
accept-charsetCharacter encodings

<input> — type values

typetypetypetype
buttoncheckboxcolordate
datetime-localemailfilehidden
imagemonthnumberpassword
radiorangeresetsearch
submitteltexttime
urlweek

<input> attributes (by group)

GroupAttributes
Identityname, 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
TagAttributes
labelfor, 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
optgrouplabel, disabled, global
optionvalue, label, selected, disabled, global
button type (submit|reset|button), name, value, disabled, form, formaction, formenctype, formmethod, formnovalidate, formtarget, popovertarget, popovertargetaction, global
fieldsetdisabled, form, name, global
legendglobal
datalistglobal — options for list
outputfor, 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>
TagAttributes
detailsopen, name (exclusive accordion group), global
summaryglobal
dialogopen, global
templateshadowrootmode, shadowrootdelegatesfocus, global
slotname, 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>
TagAttributes
script src, type, async, defer, crossorigin, integrity, nomodule, nonce, referrerpolicy, fetchpriority, blocking, attributionsrc, global
noscriptglobal
stylemedia, nonce, title, blocking, global

Gotchas & Interview Tips

  • Boolean attributes are present/absent — write required, not required="false".
  • Void elements have no end tag: img, br, hr, input, meta, link, source, track, area, col, wbr, embed, param, base.
  • Always pair label with controls via for/id or wrapping.
  • Use rel="noopener noreferrer" with target="_blank".
  • Prefer semantic tags over div/span soup; 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