Skip to main content

HTML5 elements tester

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

Sections

Elements: <body>, <article>, <section>, <nav>, <aside>, <h1>–<h6>, <header>, <footer>

<h1>–<h6>:

<h1> A unique title, specific for 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

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

  1. List item 1
  2. List item 2
    1. List item 1
  3. List item 3
    • List item 1
    • List item 2
      • List item 1
        1. List item 1
        2. List item 2
      • List item 2
    • List item 3
  4. List item 4
  • List item 1
    • List item 1
      • List item 1
    • List item 2
  • List item 2
  • List item 3
    1. List item 1
    2. 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
  1. List item 1
  2. List item 2

<figure> + <figcaption>:

Used with an <img>:

Keanu Reeves looking fine
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>

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

<img> + <svg>:

Keanu Reeves looking fine This is a fallback message. If you see this, your browser does not support inline SVG.

<picture> + <source>:

A different image will be shown depending on viewport size.

Keanu Reeves looking fine

<iframe>:

<embed>:

<object> + <param>:

<video> + <audio> + <track>:

Audio is from an example on MDN.

Video and subtitles are from an example on MDN.

<map> + <area>:

Each side of the image below is linked to different anchors on this page. Give it a try!

Keanu Reeves looking fine

<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

Forms

Elements: <form>, <label>, <input>, <button>, <select>, <datalist>, <optgroup>, <option>, <textarea>, <output>, <progress>, <meter>, <fieldset>, <legend>

<form> + <label> + <input> + <button> + <select> + <datalist> + <optgroup> + <option> + <textarea> + <fieldset> + <legend>:

Welcome to the form

<progress> + <meter>:

Testing <progress> and <meter>

Interactive elements

Elements: <details>, <summary>, <dialog>

<details> + <summary>:

This can be expanded

And by doing so, more information is revealed.

<dialog>:

This text is inside a <dialog> box! It should be hidden by default, and shown to the user when given an open attribute.

Scripting

Elements: <script>, <noscript>, <template>, <canvas>

<script> + <noscript>:

Dynamic scripts and data blocks are included with the <script> element.

If scripting is disabled when loading the page, content inside <noscript> is used instead.

<template>:

Below this paragraph, there's a <template> element containing a HTML declaration, that can be used by scripts.

<canvas>:

A <script> is used to draw a rectangle in the <canvas> below.

Alternative text explaining what's on display in this <canvas>.