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
index.html
<!DOCTYPE html>
<html lang="en">
<head>...</head>

Document Meta goes in the <head>

<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

  • Brand — logo
  • Navigation
  • Controls — search · theme selector · language selector ···
<header> header
header.html
<header>
<!-- navigation -->
<nav>
<!-- logo -->
<a href="/" class="logo">
<img src="/logo.svg" width="64" height="64" alt="Logo"/>
</a>
<!-- pages -->
<ul>
<li><a href="/blog">Blog</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
Advanced - controls — 27 collapsed lines
<!-- controls -->
<div 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>
</nav>
</header>
style.css
header {
position: fixed;
 

Headers are often styled to stay at the top of the viewport

}
  • Brand — logo · headline · socials · contact
  • Navigation
  • Legal — privacy policy · terms of service
<footer> footer
footer.html
<footer>
<div class="footer">
Brand — 19 collapsed lines
<!-- brand -->
<div 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>
</div>
<!-- pages -->
<nav>
<div class='column'>
<h3>About</h3>
<ul>
<li>Story</li>
<li>Help</li>
<li>Community</li>
</ul>
</div>
<div class='column'>
<h3>About</h3>
<ul>
<li>Story</li>
<li>Help</li>
<li>Community</li>
</ul>
</div>
</nav>
</div>
Advanced - legal — 16 collapsed lines
<!-- sub footer -->
<div class="legal">
<!-- copyright -->
<p>
&copy; 2026 Site, Inc. All rights reserved.
Designed and built by <a href="/about" rel="author">Stephen</a>.
</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>
<li><a href="/cookies">Cookie Settings</a></li>
</ul>
</nav>
</div>
</footer>

Main

  • Aside
  • Sections
  • Aside

The page content should be in <main>

<main> main
index.html
<main>
<aside>...</aside>
<section>...</section>
<aside>...</aside>
</main>

Section

Page content should be divided using <section>

<section> section
index.html
<section id='hero'>...</section>
<section id='about'>...</section>
<section id='contact'>...</section>

Aside

Aside typically contains:

  • Table of contents navigation
  • Related pages navigation
  • Comments
  • …
<aside> aside

Article

Article typically contains:

  • Forum post
  • Blog article
  • User comment
  • Widget
  • …
<article> article

Content Elements

Heading

<h1> heading — title
<h2> - <h6> heading — subtitles
<hgroup> heading group · optional
index.html
<h1>Title</h1>
<h2>Subtitle</h2>
Website

Title

Subtitle

Paragraph

<p> paragraph
index.html
<p>hello world!</p>
<p>hello world!</p>
Website

hello world!

hello world!

List

<ul> unordered list
<ol> ordered list
<li> list item
index.html
<ul>
<li>Half life</li>
<li>Death stranding</li>
<li>Cyberpunk</li>
</ul>
Website
  • Half life
  • Death stranding
  • Cyberpunk

Description List

<dl> description list
<dt> description term
<dd> description details
index.html
<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>
Website
Notch
Creator of Minecraft
Gabe Newell
Creator of Valve
Hideo Kojima
Creator of Death Stranding

Collapsible

<details> details — collapsible element
<summary> details summary — collapsible element title
index.html
<details>
<summary>Click me</summary>
Secret message
</details>
Website
Click meSecret message

Figure Elements

Table

<table> table
<tr> table row
<td> table division — cell
<th> table header — header cell

More table elements

<thead> table head · optional
<tbody> table body · optional
<tfoot> table footer · optional
<caption> table caption · optional
<colgroup> column group · optional
<col> column · optional
index.html
<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>
Website
Column 1Column 2
Cell 1Cell 2
Cell 1Cell 2

Quote

There is also an inline version of this element

<blockquote> block quote
<cite> citation · optional
index.html
<blockquote>
It's always too soon to quit
</blockquote>
<p>
<cite>Norman Vincent Peale</cite>
</p>
Website
It’s always too soon to quit

Norman Vincent Peale

Code

There is also an inline version of this element

<pre> preformatted text
<output> result output · optional
index.html
<pre>
function main() {
console.log('hello world!')
}
</pre>
<output>
hello world!
</output>
Website
function main() {
​	console.log(‘hello world!’)
}
hello world!

Image

<img src> image

Advanced image elements

<picture> picture · optional
<source type src> media source · optional
index.html
<img
src="obama-prism.gif"
width="100"
height="100"
alt="Obama Prism"
Advanced — 4 collapsed lines
fetchpriority="auto"
loading="eager"
sizes="auto"
srcset="..."
/>
Website

Audio

<audio src> audio

Advanced audio elements

<source type src> media source · optional
<track src> media text track · optional
index.html
<audio
src="fahhh.mp3"
controls

is invisible otherwise

Advanced — 5 collapsed lines
autoplay="false"
loop="false"
muted="false"
controlslist=""
preload="auto"
></audio>
Website

Video

<video src> video

Advanced video elements

<source type src> media source · optional
<track src> media text track · optional
index.html
<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>
Website

Map

<map> image map
<area> image map area
This section is currently undocumented
Let @Stephcraft know on Discord you'd like this section Documented
Join Discord

Canvas

This element requires Javascript

<canvas> canvas
index.html
<canvas width="300" height="150">
Javascript is disabled
</canvas>
Website

Embed

<iframe src> inline frame
<object type data> external object · allows fallback
index.html
<iframe
src="https://zombiecraft.net"
width="300"
height="150"
Advanced — 2 collapsed lines
sandbox=""
srcdoc=""
></iframe>
Website

Figure

<figure> figure
<figcaption> figure caption
index.html
<figure>
<img src='tun-tun-tun-sahur.png'/>
 

Showcase any element

<figcaption>
Tun Tun Tun Sahur
</figcaption>
</figure>
Website
Tun Tun Tun Sahur

Interactive Elements

<a href> anchor — link
index.html
<a href="https://zombiecraft.net">
Join my Minecraft server!
</a>
Website

Join my Minecraft server!

Open in new tab

index.html
<a
href="https://zombiecraft.net"
target="_blank"
>
Join my Minecraft server!
</a>
Website

Join my Minecraft server!

MDN Web Docs — <a target> HTML attribute

index.html
<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>
Website

Email me!

Call a fictional number!

Text a fictional number!

MDN Web Docs — <a href> HTML attribute

index.html
<a
href="https://stephcraft.net/resume.txt"
download="stephcraft-resume.txt"
>
Download my resume!
</a>
Website

Download my resume!

MDN Web Docs — <a download> HTML attribute

Relations

Links can have many relations separated by spaces

index.html
<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="prev" href="/?page=1">...</a>
 

Pagination links

  • "next" Link to the document's next page
  • "prev" Link to the document's previous page
<a rel="license" href="/license">...</a>
<a rel="privacy-policy" href="/policy" >...</a>
<a rel="terms-of-service" href="/terms" >...</a>
 

Legal links

  • "license" copyright license for the document
  • "privacy-policy" data collection and usage practices for the document
  • "terms-of-service" agreement between the user and the document provider

One of each per document · usually found in the <footer> or in the <head> as <link/>

<a rel="external" href="https://developer.mozilla.org">...</a>
<a rel="nofollow" href="https://bricksandminifigs.com">...</a>
 

Third-party links

  • "external" link is not part of this website
  • "nofollow" link is not endorsed by this document's owner
<a rel="noopener" href="...">...</a>
<a rel="noreferrer" href="...">...</a>
 

Privacy and Security link parameters

  • "noopener" excludes window.opener
  • "noreferrer" excludes window.opener and the Referer header

target="_blank" implies rel="noopener"

MDN Web Docs — rel HTML attribute

Button

Button requires Javascript to function when used outside of <form>

<button> button
index.html
<button>Click me!</button>
Website

Input

Input requires Javascript to function when used outside of <form>

<input type> user input

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

<input type=button> button
<input type=reset> reset button
<input type=submit> submit button

Textarea

Textarea requires Javascript to function when used outside of <form>

<textarea> text area input
index.html
<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>
Website

Select

Select requires Javascript to function when used outside of <form>

<select> select input
<option value> select option
<optgroup label> select option group · optional
index.html
<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>
Website

Form

<form> form
<label> label · optional
<fieldset> field set · optional
<legend> legend · optional
<output> result output · optional
Website
Contact information

Form HTML

index.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> dialog — modal
<button> button
Website

This is a dialog!

This is a popover!

Dialog HTML

index.html
<button command="show-modal" commandfor="dialog-modal">Open dialog</button>
 

A <button> can open a <dialog> with:

  • command="show-modal"
  • commandfor set to the id of the <dialog>
<dialog id="dialog-modal">
<p>This is a dialog!</p>
<button command="close" commandfor="dialog-modal">Close</button>
 

A <button> can close a <dialog> with:

  • command="close"
  • commandfor set to the id of the <dialog>
</dialog>

Popover HTML

index.html
<button popovertargetaction="show" popovertarget="popover-modal">Open dialog</button>
 

A <button> can open a <dialog popover> with:

  • popovertargetaction="show"
  • popovertarget set to the id of the <dialog popover>
<dialog id="popover-modal" popover>
<p>This is a popover!</p>
<button popovertargetaction="hide" popovertarget="popover-modal">Close</button>
 

A <button> can close a <dialog popover> with:

  • popovertargetaction="hide"
  • popovertarget set to the id of the <dialog popover>
</dialog>
<search> search
index.html
<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>
Website

You searched for ‘’

<nav> navigation
index.html
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
Website
Website
index.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.css
.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;
}
}
}

This element is equivalent to <ul>

<menu> menu
index.html
<a href='https://stephcraft.net'>
stephcraft.net
</a>
<menu>
<li><button id="copy">Copy</button></li>
<li><button id="share">Share</button></li>
</menu>
Website

stephcraft.net

  • Contact

    <address> contact address
    index.html
    <address>
    <h4>Stephcraft</h4>
    <a href="mailto:contact@stephcraft.net">
    contact@stephcraft.net
    </a>
    <a href="tel:5555555">
    (555) 555-5555
    </a>
    </address>
    Website

    Stephcraft

    contact@stephcraft.net

    (555) 555-5555

    Text Elements

    Line breaks

    <br/> line break
    <wbr/> word break opportunity
    <hr/> horizontal rule

    Text annotations

    <em> emphasis this is super duper important
    <strong> strong importance this is NOT it
    <small> small My project. All rights reserved
    <abbr> abbreviation HTML (Hyper Text Markup Language)
    <dfn> definition HTML It is the language used to structure content on the web.
    <q> quote I failed, more times than you tried
    <cite> citation — Chris Do
    <code> code println("hello world")
    <samp> sample output outputs hello world
    <kbd> keyboard input Press ctrl + shift + i to open devtools

    Text highlights

    <mark> mark — highlight highlight
    <ins cite datetime> insert added
    <del cite datetime> delete removed

    Text notations

    <var> variable 𝑥 · 𝑦
    <sup> superscript 𝑥2
    <sub> subscript H2O

    Text formatting

    <b> bold bold
    <i> italic italic
    <u> underline underline
    <s> strikethrough strikethrough

    Machine readable

    <data value> data <data value="minecraft-java">Minecraft: Java Edition</data>
    <time datetime> time <time datetime="2001-09-11">Sep 11</time>

    Data-driven

    <meter value min max> meter 30%
    <progress value max> progress 70%

    Other Elements

    Localization

    <bdi> <bdo> bidirectional · Arabic, Hebrew, …
    <ruby> <rp> <rt> ruby notation · Japanese, Chinese & Korean

    Generic

    <div> content division
    <span> content span

    Javascript

    <noscript> Javascript fallback
    <template> <slot> Web components

    XML Languages

    <svg> Scalable Vector Graphics
    <math> Mathematical Markup Language

    Meta

    <title> Title
    <meta/> Metadata
    <link href/> Link
    <script> Scripts
    <style> Stylesheets

    Resources

    HTML elements

    MDN Web Docs — HTML elements reference
    W3Schools Docs — HTML elements reference
    WHATWG Docs — HTML elements reference

    Semantic HTML

    MDN Web Docs — Structuring documents
    W3Schools Docs — HTML Semantic Elements
    Web.dev Docs — Semantic HTML

    This website is currently available on Desktop only
    Follow @Stephcraft to track the progress of the Mobile version #BuildInPublic

    Follow