HTML Cheat Sheet
Every element, every attribute - searchable, filterable by category, copy-ready with live previews.
What Is an HTML Cheat Sheet?
An HTML cheat sheet is a structured reference document that lists HTML tags, attributes, and syntax in one place for fast lookup.
It covers the full set of HTML5 elements in active use: document structure tags, text formatting, forms, tables, media, and semantic layout elements.
Who uses it: beginners building their first web page, and working developers who need a quick syntax check without digging through full documentation.
This is not a replacement for MDN Web Docs or the W3C HTML specification. It is a quick reference for the markup language syntax you already know but occasionally forget.
According to the Stack Overflow Developer Survey 2025, HTML/CSS is used by 61.9% of developers worldwide, making it the second most-used language group after JavaScript. Having that syntax close at hand matters.
HTML Document Structure Tags
Every valid HTML document requires 4 foundational tags before any content can be rendered: <!DOCTYPE html>, <html>, <head>, and <body>.
The WebAIM Million report (2026) found that 93.2% of the top 1 million home pages now use a valid HTML5 doctype, up from 79.1% in 2021. Pages without a valid doctype average fewer than half the elements of those with one.
Basic HTML5 Document Template
<!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>
<!-- content here -->
</body>
</html>
<!DOCTYPE html> goes on line 1, before anything else. No exceptions.
The lang attribute on <html> sets the document language. Screen readers and search engines both use it. Skipping it is a common oversight that affects accessibility scoring.
Essential Meta Tags
|
Tag |
Attribute |
Purpose |
|---|---|---|
|
|
|
Character encoding, supports all languages |
|
|
|
Controls mobile rendering |
|
|
|
Search result snippet text |
|
|
(content) |
Browser tab label and primary SERP title |
Placement rule: charset and viewport go first inside <head>, before any other tags.
The <link> tag connects external stylesheets. The <script> tag loads JavaScript. Both can go in <head> or just before </body>, depending on load order requirements.
HTML Text Formatting Tags
HTML has 2 distinct categories of text tags: block-level elements that start on a new line and take full width, and inline elements that flow within surrounding text.
Mixing these up causes layout bugs that can be tricky to debug, especially when nesting inline elements inside other inline elements.
Block-Level Text Tags
Headings: <h1> through <h6>, with <h1> reserved for the main page topic and <h2>–<h6> for subsections in descending importance.
Paragraph and break:
-
<p>- standard paragraph block -
<br>- line break (void element, no closing tag) -
<hr>- horizontal rule, thematic section divider
Quotation blocks:
-
<blockquote>- extended quote from external source -
<pre>- preformatted text, preserves whitespace and line breaks
Inline Text Tags
Semantic emphasis:
-
<strong>- strong importance (bold by default) -
<em>- stress emphasis (italic by default) -
<mark>- highlighted or relevant text -
<del>- deleted content -
<ins>- inserted content
Less obvious but useful:
-
<abbr title="HyperText Markup Language">HTML</abbr>- abbreviation with tooltip -
<cite>- title of a creative work -
<q>- short inline quotation (adds quotation marks automatically) -
<sub>and<sup>- subscript and superscript
W3C guidance distinguishes <b> and <i> (stylistic only) from <strong> and <em> (semantic meaning). Use semantic versions by default.
Code and Preformatted Text Tags
5 tags handle code and technical content, each with a specific role:
-
<code>- inline code snippet -
<pre>- block of preformatted text, usually wraps<code> -
<kbd>- keyboard input (user-typed keys) -
<samp>- sample output from a program -
<var>- variable in math or programming context
Most developers only use <code> and <pre>. The other 3 carry semantic meaning that helps search engines and screen readers interpret technical content correctly.
HTML List Tags
HTML has 3 list types: unordered lists, ordered lists, and description lists. Each serves a different structural purpose.
Unordered and Ordered Lists
Unordered list (<ul>) renders bullet points by default. Each item uses <li>.
Ordered list (<ol>) numbers items automatically. The type attribute controls numbering style:
|
|
Output |
|---|---|
|
|
1, 2, 3 |
|
|
A, B, C |
|
|
a, b, c |
|
|
I, II, III |
|
|
i, ii, iii |
Lists nest inside each other naturally. An <li> can contain another <ul> or <ol>, creating sub-levels with no extra attributes needed.
Description Lists
<dl>, <dt>, and <dd> build definition or key-value layouts.
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language, the structure layer of the web</dd>
</dl>
Useful for glossaries, metadata displays, and FAQ-style layouts where each term has one or more associated descriptions. Most developers overlook this list type entirely.
HTML Link and Navigation Tags
The anchor tag <a> is the single most important element in HTML for connecting content. It handles every link type: external URLs, internal pages, section jumps, email, and phone calls.
Anchor Tag Attribute Reference
|
Attribute |
Value example |
What it does |
|---|---|---|
|
|
|
Destination URL |
|
|
|
Opens in new tab |
|
|
|
Security for external links |
|
|
|
Forces file download |
Security note: target="_blank" without rel="noopener noreferrer" exposes the originating page to manipulation via the window.opener object. Always pair them.
Link Type Syntax
5 link patterns cover nearly every use case:
-
External URL:
<a href="https://example.com">Visit site</a> -
Internal page:
<a href="/about">About us</a> -
Page section:
<a href="#contact">Jump to contact</a> -
Email:
<a href="mailto:hello@example.com">Email us</a> -
Phone:
<a href="tel:+15551234567">Call us</a>
The <nav> element wraps groups of navigation links. It signals to assistive technologies and search engines that a section contains primary navigation, not just a list of links. The 2025 Web Almanac reports the native <main> element now appears on 47% of pages, up 3% from 2024, reflecting gradual improvement in semantic structure adoption overall.
HTML Image and Media Tags
4 tag categories handle visual and audio-visual content in HTML: images, figures, audio/video, and iframes.
Image Tags and Attributes
<img> is a void element. It has no closing tag. Every <img> needs at minimum src and alt.
Core attributes:
-
src- image file path or URL -
alt- text description (required for accessibility and search indexing) -
width/height- prevents layout shift during load -
loading="lazy"- defers off-screen image loading
WebAIM 2025 data shows 55.4% of images still lack alt text, down from 68% in 2019. Progress is slow. Every missing alt attribute is a direct accessibility and SEO failure.
<figure> wraps an image with its caption. <figcaption> sits inside <figure>.
<figure>
<img src="chart.png" alt="Q4 revenue by region">
<figcaption>Q4 2024 revenue breakdown across 5 regions</figcaption>
</figure>
Audio and Video Tags
<audio> and <video> share a similar attribute pattern:
-
controls- shows browser-native playback UI -
autoplay- starts on load (use sparingly, bad UX) -
loop- repeats after finishing -
muted- required for autoplay to work in most browsers -
poster(video only) - thumbnail shown before playback starts
Both support the <source> child element for providing multiple formats with fallback:
<video controls width="640">
<source src="intro.webm" type="video/webm">
<source src="intro.mp4" type="video/mp4">
</video>
Iframe Embed Tag
<iframe> embeds external content: maps, videos, third-party widgets.
Required attributes: src, width, height, title (for accessibility), and allowfullscreen when embedding video players.
The title attribute on <iframe> is frequently skipped. Screen readers announce iframe content to users. Without a descriptive title, the embedded content has no accessible label.
HTML Table Tags
A complete HTML table uses 7 elements: <table>, <thead>, <tbody>, <tfoot>, <tr>, <th>, and <td>.
Skipping <thead> and <tbody> works visually but breaks screen reader table navigation and makes the DOM harder to parse.
Table Structure Reference
|
Element |
Role |
|---|---|
|
|
Container for the entire table |
|
|
Groups header rows |
|
|
Groups body/data rows |
|
|
Groups footer rows (totals, summaries) |
|
|
Single row |
|
|
Header cell (bold, centered by default) |
|
|
Data cell |
|
|
Visible table title, improves accessibility |
Spanning and Accessibility Attributes
colspan merges cells horizontally. rowspan merges cells vertically.
<td colspan="2">Spans two columns</td>
<td rowspan="3">Spans three rows</td>
The scope attribute on <th> tells screen readers which cells a header applies to:
-
scope="col"- header for the entire column below -
scope="row"- header for the entire row to the right -
scope="colgroup"/scope="rowgroup"- header spans multiple columns or rows
<caption> is placed immediately after <table>. Only about 1.6% of desktop sites include table captions (Web Almanac 2025), despite captions being one of the most straightforward accessibility improvements available.
CSS handles table layout now. Using <table> for page layout (not data) is a legacy pattern. Add role="presentation" if a layout table absolutely cannot be removed.
HTML Form Tags and Input Types
Forms are where HTML does real work. A <form> element wraps all input controls and defines where and how collected data gets sent.
State of HTML 2023 data shows the most-used HTML input types across surveyed developers: number at 94%, email at 89%, file at 88%, and date at 83%.
Form Structure Tags
The 3 form structure tags every form needs:
-
<form>- container;actionsets where data goes,methodsets how (GET or POST) -
<fieldset>- groups related inputs;<legend>labels the group for screen readers -
<label>- connects text to its input via theforattribute, matching the input'sid
WebAIM 2025 found 34.2% of form inputs are not properly labeled, covering 6.3 form inputs per home page on average.
Input Types Reference
HTML currently supports 22 input types. The ones you'll reach for most often:
|
Type |
Use case |
|---|---|
|
|
Default single-line text |
|
|
Email with built-in format validation |
|
|
Masked text input |
|
|
Numeric input with step controls |
|
|
Boolean selection |
|
|
Single-choice from a group |
|
|
File upload dialog |
|
|
Date picker |
|
|
Slider control |
|
|
Data sent with form but not shown to users |
|
|
Form submission button |
Form Validation Attributes
Built-in HTML5 validation handles most common input rules without JavaScript.
required - field must have a value before submission.
pattern - validates input against a regex string.
min / max - numeric and date range boundaries.
maxlength - caps character count for text inputs.
placeholder - hint text inside the input, not a substitute for <label>.
A common mistake: using placeholder as the only label. It disappears the moment a user starts typing, leaving no visible description.
Additional Form Elements
4 elements handle dropdown and multi-option scenarios:
-
<select>with<option>items builds a dropdown -
<optgroup>clusters related options inside a<select> -
<datalist>provides autocomplete suggestions for a text input (linked vialistattribute) -
<textarea>handles multi-line text; userowsandcolsor CSS for sizing
<button type="submit"> submits the form. <button type="reset"> clears all inputs. <button type="button"> does nothing by default but triggers JavaScript handlers.
HTML Semantic Structure Tags
Semantic HTML5 tags define page layout regions. They replace generic <div> elements with tags that carry built-in meaning for browsers, assistive technologies, and search engines.
The <main> element now appears on 42.6% of home pages, up from 39.1% in 2024, according to WebAIM 2025. Still less than half. Most pages are still using non-semantic wrappers for primary content.
Page Layout Semantic Elements
<header> - introductory content or a group of navigational links. Can appear once at page level or inside <article> and <section> elements.
<footer> - closing content: copyright, author info, related links. Same nesting rules as <header>.
<main> - the dominant content of the document. Only one <main> per page.
<nav> - primary navigation links. Not every group of links qualifies; use it for major navigation blocks only.
<aside> - content tangentially related to the surrounding context, like sidebars or pull quotes.
Content Sectioning Tags
<section> vs <article> is a distinction most developers get wrong at some point.
<article> is self-contained content that makes sense distributed independently: blog posts, news stories, forum threads, product cards.
<section> groups thematically related content within a page. It should have a heading. If you can't give it a heading, it probably wants to be a <div>.
<time> marks dates and times with a machine-readable datetime attribute:
<time datetime="2024-11-15">November 15, 2024</time>
<address> marks contact information related to the nearest <article> or <body> ancestor.
HTML Global Attributes
Global attributes apply to every HTML element. They are not tag-specific.
ARIA attribute usage has quadrupled since 2019, with pages now averaging 89 ARIA attributes each, according to WebAIM 2025. But pages with ARIA present show over twice as many accessibility errors as those without, averaging 57 errors vs. 27.
Core Global Attributes
|
Attribute |
What it does |
|---|---|
|
|
Unique identifier for the element on the page |
|
|
One or more CSS class names for styling or JS targeting |
|
|
Inline CSS (use sparingly) |
|
|
Tooltip text on hover |
|
|
Language of the element's content |
|
|
Text direction: |
|
|
Hides the element from display and accessibility tree |
|
|
Controls keyboard navigation order |
|
|
Makes element content directly editable by the user |
Data Attributes and ARIA
data-* attributes store custom data on elements for JavaScript to read. The Web Almanac 2024 found data-id is used on 24% of mobile pages, making it the most popular custom data attribute.
<div data-product-id="4821" data-category="tools">...</div>
ARIA attributes communicate accessibility information to screen readers:
-
aria-label- provides a text label when visible text is absent -
aria-hidden="true"- removes an element from the accessibility tree -
role- assigns an explicit semantic role (use native HTML elements first)
The rule on ARIA: native HTML semantics always take priority. role="button" on a <div> is a workaround for not using <button>. Start with the right element and ARIA becomes rarely needed.
HTML Character Entities and Symbols
Some characters have special meaning in HTML markup and need to be escaped: <, >, &, and ". Use named or numeric character entities instead.
Reserved Character Entities
You must escape these when they appear as literal content:
-
<renders< -
>renders> -
&renders& -
"renders" -
'renders' -
renders a non-breaking space (no line wrap at that point)
Common Symbol Entities
|
Entity name |
Numeric |
Renders |
|---|---|---|
|
|
|
© |
|
|
|
® |
|
|
|
™ |
|
|
|
€ |
|
|
|
£ |
|
|
|
- |
|
|
|
– |
|
|
|
… |
Named entities like © are easier to read in source. Numeric references like © work in any environment.
UTF-8 charset removes most problems. With <meta charset="UTF-8"> in <head>, you can paste most special characters directly into HTML without entities. The exceptions are still the 4 reserved characters above.
HTML Meta Tags for SEO and Social Sharing
Meta tags in <head> control how search engines index your page and how it appears when shared on social platforms.
According to the Web Almanac 2024, og:title appears on 61% of mobile pages, og:url on 58%, and og:description on 53%. Title tags appear on 99.1% of pages.
SEO Meta Tags
<title> - the primary ranking and click signal in search results. Keep it under 60 characters.
<meta name="description"> - shown as the snippet in search results. Removing it can hurt click-through rates. One experiment removed title tags and meta descriptions from a $200,000/year site; traffic dropped 25% within two weeks (Ahrefs case study).
<meta name="robots"> - controls crawler behavior. Common values:
-
index, follow- default behavior (no need to add explicitly) -
noindex- blocks the page from appearing in search results -
- tells crawlers not to follow links on the page
<link rel="canonical"> - specifies the preferred URL when duplicate or near-duplicate versions exist. Canonical adoption reached 67% of pages in 2025 (Web Almanac 2025), up from 65% in 2024.
Open Graph and Twitter Card Tags
Open Graph controls link previews on Facebook, LinkedIn, and Slack. Twitter Cards handle the same for X (formerly Twitter).
Minimum Open Graph tags needed for a working preview:
<meta property="og:title" content="Page Title Here">
<meta property="og:description" content="Brief description under 160 characters">
<meta property="og:image" content="https://example.com/image.jpg">
<meta property="og:url" content="https://example.com/page">
Twitter Card minimum:
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Page Title Here">
<meta name="twitter:image" content="https://example.com/image.jpg">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> - required for responsive mobile rendering. Viewport meta tags now appear on over 93% of pages (Web Almanac 2025).
Deprecated HTML Tags Still Found in Legacy Code
Deprecated tags were removed from HTML5 because CSS handles their function better. They still render in modern browsers for backward compatibility, but they carry no semantic meaning and fail accessibility checks.
12% of mobile pages still use document.write, a legacy JavaScript pattern closely tied to deprecated HTML practices, according to Web Almanac 2024.
Deprecated Presentational Tags
These replaced by CSS properties completely:
|
Deprecated tag |
Use this instead |
|---|---|
|
|
CSS |
|
|
CSS |
|
|
CSS |
|
|
CSS |
|
|
CSS |
|
|
CSS |
|
|
|
Deprecated Structural Tags
<frame>, <frameset>, <noframes> - frame-based page layouts from the 1990s. Fully removed in HTML5. Replace with CSS layout or <iframe> where embedding is needed.
<acronym> - use <abbr> with a title attribute instead:
<abbr title="HyperText Markup Language">HTML</abbr>
<applet> - loaded Java applets. Replace with <object> or modern JavaScript equivalents.
Spotting deprecated tags in a codebase is a reliable signal of how long the project has gone without a markup audit. Running pages through the W3C Validator at validator.w3.org takes under a minute and flags every deprecated element in the source.
If you're working on front-end development in an older project, a quick pass through the HTML to replace deprecated tags with semantic equivalents is one of the fastest ways to improve both accessibility scores and code maintainability. The css cheat sheet covers the CSS replacement properties for every deprecated presentational tag above.
FAQ on HTML Cheat Sheet
What is an HTML cheat sheet used for?
An HTML cheat sheet is a quick reference for HTML tags, attributes, and syntax. Developers use it to look up correct markup without opening full documentation. It covers everything from document structure to form elements, semantic tags, and character entities.
What are the most important HTML tags to know?
The tags you'll use in every project: <html>, <head>, <body>, <div>, <p>, <a>, <img>, <h1>–<h6>, <ul>, <li>, and <form>. Semantic elements like <main>, <nav>, and <footer> are equally important for accessibility.
What is the difference between HTML elements and HTML attributes?
An element is the tag itself, like <input>. An attribute modifies that element's behavior or appearance, like type="email" or required. Attributes always sit inside the opening tag and come in name-value pairs.
What HTML tags are deprecated in HTML5?
Tags like <font>, <center>, <strike>, <tt>, and <big> were removed in HTML5. CSS handles their styling functions now. <frame> and <frameset> were also dropped entirely. Use semantic HTML and CSS instead of these legacy elements.
What is the correct HTML5 document structure?
Start with <!DOCTYPE html>, followed by <html lang="en">, then <head> (for meta tags, title, and stylesheet links), then <body> for all visible content. The charset and viewport meta tags belong at the top of <head>.
What is the difference between <div> and semantic HTML tags?
<div> carries no meaning. It is a generic container. Semantic tags like <article>, <section>, and <aside> tell browsers and screen readers what the content represents. Use semantic tags first, and reach for <div> only when no semantic option fits.
How do HTML forms work?
A <form> element wraps input controls and sends collected data to a server via the action and method attributes. Input types like email, number, and date provide built-in browser validation. Every input needs a <label> linked by matching id and for values.
What are HTML character entities and when do you need them?
Character entities encode reserved characters that HTML would otherwise interpret as markup. < renders <, & renders &, and inserts a non-breaking space. With UTF-8 charset declared, most special symbols can be typed directly into HTML source.
What HTML meta tags matter for SEO?
The <title> tag and <meta name="description"> directly affect search result appearance and click-through rates. Open Graph tags (og:title, og:image, og:url) control social media previews. The <link rel="canonical"> tag prevents duplicate content issues across multiple URLs.
How is an HTML cheat sheet different from full HTML documentation?
Full documentation like MDN Web Docs covers every attribute, browser compatibility table, and edge case. A cheat sheet gives you syntax at a glance: the tag, its key attributes, and a usage example. It is faster for daily lookup, not for learning a new concept from scratch.