Semantic HTML
Using structured semantic HTML elements within the <body> of an HTML page is a form of SEO that enhances machine readability.
HTML Elements
There are 115 HTML elements
HTML Layout
- Header
- Main
- Footer
<!DOCTYPE html><html lang="en"><body> Document Content goes in these elements:
<header>...</header> <main>...</main> <footer>...</footer></body></html>Other special elements may be in the
<body>, such as:
- Toast notifications
- Modals
- Special fx
- …
MDN Web Docs — Structuring documents
Header
- Brand — logo
- Navigation
- Controls — search · theme selector · language selector ···
<header> <!-- logo --> <a href="/" class="logo"> <img src="/logo.svg" width="64" height="64" alt="Logo"/> </a> <!-- pages --> <nav> <ul> <li><a href="/blog">Blog</a></li> <li><a href="/about">About</a></li> <li><a href="/contact">Contact</a></li> </ul> </nav>Advanced - controls — 27 collapsed lines
<!-- controls --> <div role="toolbar" class="controls"> <!-- search --> <form role="search" action="/search" method="get" class="search-form"> <label for="site-search" class="sr-only">Search site</label> <input type="search" id="site-search" name="q" placeholder="Search..." autocomplete="off"> </form> <!-- theme switcher --> <input type="checkbox" id="theme-toggle" class="sr-only"> <label for="theme-toggle" class="theme-switch" aria-label="Toggle dark mode"></label> <!-- language selector --> <details class="language-dropdown"> <summary aria-label="Select Language">English (EN)</summary> <ul> <li><a href="/en/" hreflang="en" lang="en">English</a></li> <li><a href="/fr/" hreflang="fr" lang="fr">Français</a></li> <li><a href="/es/" hreflang="es" lang="es">Español</a></li> </ul> </details> <!-- Subscribe to newsletter --> ... </div> <!-- authentication --> <ul> <li><a href="/login">Login</a></li> <li><a href="/signup">Sign up</a></li> </ul> </header>Footer
- Brand — logo · headline · socials · contact
- Navigation
- Legal — privacy policy · terms of service
<footer> <section id="footer">Brand — 19 collapsed lines
<!-- brand --> <hgroup class="brand"> <!-- logo --> <h2> <a href="/" class="logo"> <img src="/logo.svg" width="64" height="64" alt="Logo"/> </a> </h2> <!-- headline --> <p>...</p> <!-- social media --> <nav class="social-links" aria-label="Social Media"> <ul> <li><a rel="me" href="https://github.com/..." aria-label="GitHub">GitHub</a></li> <li><a rel="me" href="https://discord.com/..." aria-label="Discord">Discord</a></li> <li><a rel="me" href="https://twitter.com/..." aria-label="X">X</a></li> </ul> </nav> </hgroup> <!-- pages --> <nav> <hgroup> <h3>About</h3> <ul> <li>Story</li> <li>Help</li> <li>Community</li> </ul> </hgroup> <hgroup> <h3>About</h3> <ul> <li>Story</li> <li>Help</li> <li>Community</li> </ul> </hgroup> </nav> </section>Additional sections — 15 collapsed lines
<section id="legal"> <!-- copyright --> <p>© 2026 Site, Inc. All rights reserved.</p> <!-- legal documents --> <nav aria-label="Legal Navigation"> <ul> <li><a rel="privacy-policy" href="/privacy">Privacy Policy</a></li> <li><a rel="terms-of-service" href="/terms">Terms of Service</a></li> </ul> </nav> </section> <section id="credit"> <!-- credit --> <p>Designed and built by <a href="/about" rel="author">Stephcraft</a></p> </section> </footer>Main
- Aside
- Sections
- Aside
The page content should be in
<main>
<main> <aside>...</aside> <section>...</section> <aside>...</aside></main>Section
Page content should be divided using
<section>
<section id='hero'>...</section><section id='about'>...</section><section id='contact'>...</section>Aside
Aside typically contains:
- Table of contents navigation
- Related pages navigation
- Comments
- …
Article
Article typically contains:
- Forum post
- Blog article
- User comment
- Widget
- …
Content Elements
Heading
<h1>Title</h1><h2>Subtitle</h2>Paragraph
<p>hello world!</p><p>hello world!</p>List
<ul> <li>Half life</li> <li>Death stranding</li> <li>Cyberpunk</li></ul>Description List
<dl> <dt>Notch</dt> <dd>Creator of Minecraft</dd> <dt>Gabe Newell</dt> <dd>Creator of Valve</dd> <dt>Hideo Kojima</dt> <dd>Creator of Death Stranding</dd></dl>Collapsible
<details> <summary>Click me</summary> Secret message</details>Figure Elements
Table
More table elements
<table> <tr> <th>Column 1</th> <th>Column 2</th> </tr> <tr> <td>Cell 1</td> <td>Cell 2</td> </tr>4 collapsed lines
<tr> <td>Cell 1</td> <td>Cell 2</td> </tr> </table>Quote
<blockquote> It's always too soon to quit</blockquote><p> <cite>Norman Vincent Peale</cite></p>Code
<pre> function main() { console.log('hello world!') }</pre><output> hello world!</output>Image
<img src="obama-prism.gif" width="100" height="100" alt="Obama Prism"Advanced — 4 collapsed lines
fetchpriority="auto" loading="eager" sizes="auto" srcset="..." />
Audio
Advanced audio elements
<audio src="fahhh.mp3" controls is invisible otherwise
Advanced — 5 collapsed lines
autoplay="false" loop="false" muted="false" controlslist="" preload="auto" ></audio>Video
Advanced video elements
<video src="video.mp4" width="200" height="200" controls is static otherwise
Advanced — 6 collapsed lines
autoplay="false" loop="false" muted="false" controlslist="" poster="" preload="auto" ></video>Map
Canvas
This element requires Javascript
<canvas width="300" height="150"> Javascript is disabled</canvas>Embed
<iframe src="https://zombiecraft.net" width="300" height="150"Advanced — 2 collapsed lines
sandbox="" srcdoc="" ></iframe>Figure
<figure> <img src='tun-tun-tun-sahur.png'/> Showcase any element
<figcaption> Tun Tun Tun Sahur </figcaption></figure>
Interactive Elements
Link
<a href="https://zombiecraft.net"> Join my Minecraft server!</a> Open in new tab
<a href="https://zombiecraft.net" target="_blank"> Join my Minecraft server!</a> Contact links
<a href="mailto:contact@stephcraft.net"> Email me!</a><a href="tel:5555555"> Call a fictional number!</a><a href="sms:5555555"> Text a fictional number!</a>Email me!
Call a fictional number!
Text a fictional number!
Download link
<a href="https://stephcraft.net/resume.txt" download="stephcraft-resume.txt"> Download my resume!</a>Download my resume!
Relations
<a rel="me" href="https://github.com/Stephcraft">...</a><a rel="author" href="https://stephcraft.net" >...</a><a rel="bookmark" href="/blog/ai" >...</a><a rel="tag" href="/blog/tags/typescript" >...</a><a rel="search" href="/search" >...</a><a rel="help" href="/help" >...</a> Document links
"me" Link represents the document's owner · useful for socials
"author" Link to an author of the document or article
"bookmark" Permalink for the article or document
"tag" Link to a tag applied to this document
"search" Link to search through the document and its related pages
"help" Link to context-sensitive help
<a rel="next" href="/?page=3">...</a>
<a rel="license" href="/license">...</a><a rel="privacy-policy" href="/policy" >...</a><a rel="terms-of-service" href="/terms" >...</a>
<a rel="external" href="https://developer.mozilla.org">...</a>
<a rel="noopener" href="...">...</a>Button
Button requires Javascript to function when used outside of
<form>
<button>Click me!</button>Input
Input requires Javascript to function when used outside of
<form>
Specialized
<input type=checkbox> |
checkbox | |
<input type=radio> |
radio | |
<input type=range> |
range | |
<input type=color> |
color | |
<input type=file> |
file |
Textbox
<input type=text> |
text | |
<input type=number> |
number | |
<input type=email> |
||
<input type=tel> |
telephone | |
<input type=url> |
url | |
<input type=password> |
password | |
<input type=search> |
search |
Date time
<input type=date> |
date | |
<input type=month> |
month & year | |
<input type=week> |
week & year | |
<input type=datetime-local> |
date time | |
<input type=time> |
time |
Button
Textarea
Textarea requires Javascript to function when used outside of
<form>
<textarea rows="2" cols="20" placeholder="Enter text here..."Advanced — 6 collapsed lines
autocapitalize autocomplete="on" autocorrect="on" spellcheck="default" minlength="10" maxlength="100" > Alot of text can be put in here!</textarea>Select
Select requires Javascript to function when used outside of
<form>
<select> <option>Choose an option</option> <option value="html">HTML</option> <option value="css">CSS</option> <option value="js">JS</option>Option group — 5 collapsed lines
<optgroup label="Legacy"> <option value="php">PHP</option> <option value="flash">Flash</option> <option value="java">JApplet</option> </optgroup> </select>Form
<form> |
form |
<label> |
label · optional |
<fieldset> |
field set · optional |
<legend> |
legend · optional |
<output> |
result output · optional |
Form HTML
<form action="" method="get"> <fieldset> <legend>Contact information</legend>
<label> Enter your name: <input type="text" name="name" required/> </label>
<label> Enter your email: <input type="email" name="email" required/> </label>
</fieldset>
<input type="submit" value="Subscribe!"/></form>Dialog
Dialog HTML
<dialog id="dialog-modal"> <p>This is a dialog!</p></dialog> Popover HTML
<dialog id="popover-modal" popover> <p>This is a popover!</p></dialog>Search
<search> <form action="/search"> <label for="movie">Find a Movie</label> <input type="search" id="movie" name="q"/> <button type="submit">Search</button> </form></search>Navigation
<nav> <ul> <li><a href="/">Home</a></li> <li><a href="/about">About</a></li> <li><a href="/contact">Contact</a></li> </ul></nav> Breadcrumbs HTML
<nav class="breadcrumbs"> <ol> <li><a href="/blog">Blog</a></li> <li><a href="/blog#web">Web</a></li> <li>Semantic HTML</li> </ol></nav>.breadcrumbs ol { list-style-type: none; padding-left: 0;
li { display: inline-block;
a::after { display: inline-block; color: black; content: "▸"; font-size: 80%; font-weight: bold; padding: 0 3px; } }}Menu
This element is equivalent to
<ul>
<a href='https://stephcraft.net'> stephcraft.net</a><menu> <li><button id="copy">Copy</button></li> <li><button id="share">Share</button></li></menu>Contact
<address> <h4>Stephcraft</h4> <a href="mailto:contact@stephcraft.net"> contact@stephcraft.net </a> <a href="tel:5555555"> (555) 555-5555 </a></address>Stephcraft
(555) 555-5555
Text Elements
Line breaks
Text annotations
Text highlights
<mark> |
mark — highlight | highlight |
<ins cite datetime> |
insert | added |
<del cite datetime> |
delete |
Text notations
Text formatting
Machine readable
<data value> |
data | <data value="minecraft-java">Minecraft: Java Edition</data> |
<time datetime> |
time | <time datetime="2001-09-11">Sep 11</time> |