HTML elements
posted in design on 7th Jan 2025
7 minute read
A test page containing most of the HTML5 elements that you'll ever need. Useful for testing CSS resets or CSS frameworks.
A project by Alexander Sandberg · GitHub repository
Navigation
- Sections
- Grouping content
- Text-level semantics
- Edits
- Embedded content
- Tabular data
- Forms
- Interactive elements
- Scripting
Sections
Elements: <body>, <article>, <section>, <nav>, <aside>, <h1>–<h6>, <header>, <footer>
<h1>–<h6>:
<h1> A unique title
This should be specific to the page.
<h2> Heading levels should reflect structure, not style
It can also be useful to test how body text below a heading appears on the page, for example to check the margin. This text is wrapped in <p> and is a direct sibling to the above <h2>.
<h3> If you need a visually smaller title, use CSS
To create a semantically correct HTML structure that's accessible for everyone, make sure you're nesting the headings correctly. Never use more than one <h1> per page, and don't skip heading levels.
<h4> Headings below level 4 are not used as much
<h5> But that doesn't mean you should forget about them
<h6> And last, but not least, the heading with the lowest rank
<body> + <article> + <section> + <nav> + <aside> + <header> + <footer>:
All these tags are already in use on the page. The list below contains links to each use case. See the source code of this file for more details.
Grouping content
Elements: <p>, <address>, <hr>, <pre>, <blockquote>, <ol>, <ul>, <li>, <dl>, <dt>, <dd>, <figure>, <figcaption>, <main>, <div>
<p>:
Paragraphs are usually represented in visual media as blocks of text separated from adjacent blocks by blank lines and/or first-line indentation, but HTML paragraphs can be any structural grouping of related content, such as images or form fields. [1]
<address>:
Name: Alexander Sandberg
Street adress: 1 Rover street
State: N/A
Planet: Mars
Digital home: alexandersandberg.com
<hr>:
<pre>:
Preformatted text will be presented exactly as written in the HTML file.
<blockquote>:
The text inside this blockquote is wrapped in
<p>tags. Sometimes the quote is really long, and possibly have to occupy multiple lines, but that shouldn't be a problem.
<ol> + <ul> + <li>:
- List item 1
- List item 2
- List item 1
- List item 3
- List item 1
- List item 2
- List item 1
- List item 1
- List item 2
- List item 2
- List item 1
- List item 3
- List item 4
- List item 1
- List item 1
- List item 1
- List item 2
- List item 1
- List item 2
- List item 3
- List item 1
- List item 2
<dl> + <dt> + <dd>:
This is a term
And this is the accompanying description, explaining the above term.
You can also have multiple descriptions (<dt>), like this one, for each term (<dt>).
And why not nest lists inside this description?
Another term
With some description.
- List item 1
- List item 1
- List item 2
<figure> + <figcaption>:
Used with an <img>:

Wholesome Keanu Reeves from placekeanu.com.
Used with a <blockquote>:
Seek wealth, not money or status. Wealth is having assets that earn while you sleep. Money is how we transfer time and wealth. Status is your place in the social hierarchy.
Naval Ravikant (@naval) on Twitter.
<main>:
See the main content of this page for a use case of <main>.
<div>:
This paragraph of text is contained inside a <div>. The element really has no special meaning, other than grouping content together, and should be used as a last resort when no other element is suitable.
Text-level semantics
Elements: <a>, <em>, <strong>, <small>, <s>, <cite>, <q>, <dfn>, <abbr>, <ruby>, <rb>, <rt>, <rtc>, <rp>, <data>, <time>, <code>, <var>, <samp>, <kbd>, <sub>, <sup>, <i>, <b>, <u>, <mark>, <bdi>, <bdo>, <span>, <br>, <wbr>
<a>:
Here is a link inside a paragraph of text. Below you can find a list of links with different href attributes.
- Link to an external website
- Anchor link to this element
- Link with an empty
hrefattribute - Link missing an
hrefattribute
<em> + <i> + <strong> + <b>:
The <em> element represents stress emphasis of its contents. Meanwhile, <i> is since HTML5 used for text in an alternative voice or mood, or otherwise offset from the normal prose, as you may define it.
If you want to draw attention to some text, feel free to use <b>. However, if you want to mark the importance of something, you should use <strong>.
<small> + <u> + <mark> + <s>:
When you want your text to represent small print, use <small>.
In most cases, there's a better element than <u> to use, but it can be useful for labelling msispelt text. Avoid using it, however, where the text could be confused for a hyperlink.
You can highlight text for reference purposes with <mark>, or if the contents is ~no longer accurate or relevant~, wrap it with <s>.
<abbr> + <dfn>:
By wrapping an abbreviation like CSS in both <dfn> and <abbr>, we define the term. This can later be used only using <abbr>, since we already defined CSS once before.
<q> + <cite> + <data> + <time>:
When citing creative work, include the reference with a <cite> element. www.w3.org explains that A citation is not a quote (for which the <q> element is appropriate) instead, like used here.
If you want to link content with a machine-readable translation, use <data> with a value attribute. However, if this data is a time- or date-related, like the date July 4, you have to use <time> together with the datatime attribute.
<code> + <var> + <samp> + <kbd> + <sub> + <sup>:
When sharing code-snippets, make sure to use the <code> element. This can be done both display: inline;, as well as block-level:
* {
color: rebeccapurple;
background: aliceblue;
}Variables should be surrounded by <var>, or x amount of people might be confused.
Sample or quotes output are represented with <samp>: Your expression '1 + 1' equals 2.
To represent user input, like the shortcut Cmd + R on macOS, use <kbd>.
If you want to subscript or superscript text, use <sub> or <sup>.
<bdi> + <bdo> + <ruby> + <rb> + <rt> + <rtc> + <rp>:
Consider using <bdi> when working with bidirectional content, like the names Alexander and علي.
If you need to override the bidirectional algorithm for some content and its children, use <bdo>:
Don't forget to specify the dir attribute!
I said, don't forget to specify the dir attribute!
Some use of <ruby> and its related elements:
漢 (Kan) 字 (ji)
旧金山jiùjīnshānSan Francisco
More information about the explanation and usage of these can be read here on www.w3.org.
<span> + <br> + <wbr>:
A <span> can be used to mark up inline text for various uses, here to make the text bolder.
If you have really long text you might want to insert a
blank line with the <br> element. You can also insert word breaking opportunities using <wbr>, to help the browser break long words like Pneumonoultramicroscopicsilicovolcanoconiosis.
Edits
Elements: <ins>, <del>
<ins> + <del>:
If you make a ~really huge~ mistake, you can always go back and fix it later. And don't forget to learn from your mistake.
Both <ins> and <del> can be block-level, like this.
~
Here's a block-level paragraph removal.
~
Embedded content
Elements: <picture>, <source>, <img>, <iframe>, <embed>, <object>, <param>, <video>, <audio>, <track>, <map>, <area>, <math>, <svg>
<iframe>:
<embed>:
<object> + <param>:
<video> + <audio> + <track>:
This is a fallback text. If you see this, your browser does not support embedded audio.
Audio is from an example on MDN.
This is a fallback text. If you see this, your browser does not support embedded videos.
Video and subtitles are from an example on MDN.
<math>:
The quadratic formula is:
x \= - b ± b 2 - 4 a c 2 a
Tabular data
Elements: <table>, <caption>, <colgroup>, <col>, <tbody>, <thead>, <tfoot>, <tr>, <td>, <th>
<table> + <caption> + <colgroup> + <col>+ <tbody> + <thead> + <tfoot> + <tr> + <td> + <th>:
| --- | --- | --- | --- | This is the table caption | <thead> | 2nd colgroup | 2nd colgroup | 3rd colgroup | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
<tbody> | This is a cell spanning two columns | Last column | |||||||||||
<tfoot> | Cell 2 | Cell 3 | Cell 4 |
About this project
A test page containing most of the HTML5 elements that you'll ever need. Useful for testing CSS resets or CSS frameworks.
HTML5 elements tester by Alexander Sandberg.