Code has been added to clipboard!

HTML5 Semantic Tags: What Is Semantic Markup?

Reading time 4 min
Published Jun 22, 2017
Updated Jan 21, 2020

TL;DR – HTML5 semantic tags define the function and the category of your text, simplifying the work for browsers and search engines, as well as developers.

The Origins of HTML5 Semantic Tags


In earlier versions of HTML, there were no globally accepted names for structural elements, and each developer used their own. That made it very hard for search engines to index web page content correctly.

When a browser communicates with the code, it looks for some specific information to help with the display. Hence, HTML5 introduced a consistent list of semantic elements to help search engines and developers.

HTML5 semantic tags define the purpose of the element. By using semantic markup, you help the browser understand the meaning of the content instead of just displaying it. By providing this extra level of clarity, HTML5 semantic elements also help search engines to read the page and find the required information faster.

Semantic Markup for Document Structure

First, we will discuss the HTML5 elements you can see in the illustration above. They are used to convey the structure of the document in a clear manner.

The <header> element defines a header of your document. It is always visible for the users at the top of the page:

Example
<header>
 <h1>JavaScript</h1>
 <h3>What is JavaScript?</h3>
 <p>Today we are going to talk about JavaScript</p>
</header>

<nav> depicts the space for navigation links on your website:

Example
<nav>
  <ul>
    <li><a href="https://www.bitdegree.org/tag/gamified/">Gamified Courses</a></li>
    <li><a href="https://www.bitdegree.org/tutorials/">Tutorials</a></li>
    <li><a href="https://www.bitdegree.org/course/learn-solidity-space-doggos/">Space doggo courses</a></li>
    <li><a href="https://www.bitdegree.org/tag/game-dev/">Game Dev Courses</a></li>
  </ul>
</nav>

The <section> tags are used to define a separate section within a webpage, with its own content:

Example
<section>
  <h1>Section Heading</h1>
  <p>The section tag can contain any elements.</p>
  <img src="image.png" alt="section example">
</section>

The <article> element can be used to define the article content on your website:

Example
<article>
  <h1>Fun Fact</h1>
  <p>Fun fact: most of the fun facts on the Internet are not actually fun.</p>
</article>

The <aside> semantic element defines the content which will be set to the side. It is occasionally used for creating sidebars, but can also be used for displaying less important content:

Example
<aside>
  <h4>Lake</h4>
  <p>Oxford lake is a lake in the state.</p>
</aside>

The HTML5 <footer> element describes the footnote for your website or part of the content:

Example
<footer>
  <address>
    Postal Address: Door No.00, Street, City, State, Country.
  </address>
  <p>Copyright © 2018 All rights reserved.</p>
</footer>

Other Commonly Used Semantic Tags

The <figure> element depicts space for separated content, such as photos, diagrams, etc. To provide a caption for this element, use the <figcaption> tags:

Example
<figure>
  <figcaption>Dog</figcaption>
  <img src="image.png" alt="The Bread Dog" width="300" height="300">
</figure>

The <details> element defines the details on your website that can either be visible or hidden. To add a summary for this element, use the <summary> element:

Example
<details> 
   <summary>Some details</summary> 
   <p>Provide more info about the details here.</p>
</details>

The content of the <main> tags is the main content of a page. It can be an article, regular paragraph or anything else:

Example
<main id="content" class="group" role="main">

The <mark> element highlights the text to emphasize its meaning:

Example
<p>The mark tag is <mark>useful</mark> when you need to highlight important information</p>

The <time> element is used to define and display time and date on your web page:

Example
<h2>The premiere show starts at <time>21:00</time> today.</h2>

The <img> tags are used to add an image on your website:

Example
<img src="image.png" alt="Space Doggo" width="50" height="50">

The <form> element allows you to include user input:

Example
<form action="search" method="GET">
  Search Term: <input type="text" name="search_query">
  <input type="submit" value="Search">
</form>

The <table> tags are used to add a table with rows and columns on a web page:

Example
<table>
  <tr>
    <th>Place</th>
    <th>Animal</th>
  </tr>
  <tr>
    <td>Space</td>
    <td>Dog</td>
  </tr>
</table>

HTML5 Semantic Tags: Useful Tips

  • Semantic HTML is also important for accessibility, especially as the number of smart devices keeps growing. It simplifies page navigation for assistive technologies as well.
  • HTML5 elements that help you deal with foreign alphabets are also called semantic – e.g., take a look at <bdi> and <ruby> tags.
  • Using HTML5 semantic tags also makes it easier to create consistent styling with CSS, as you can easily select all similar elements.
Basics
Introduction
Syntax
Editors
Basic Examples
Head Section
<!DOCTYPE>
Tags and Elements
Semantic Elements
Tags Reference
Attributes
Comments
Block and Inline Elements
Forms
Form Elements
Input
Responsive Web Design
Inline Scripts
Uniform Resource Locator
Redirect
XHTML
Geolocation
Drag and Drop
Local Storage
Web Workers
Server-Sent Events
Character Encoding
Text Formatting
Quotation and Citation Elements
Headings
Paragraphs
Links
Tables
Lists
Symbols
Space
Tab
Styles
Computer Code
Layout
Classes
Colors
Images
iframes
Audio Player
Video Player
YouTube Videos
Multimedia
Canvas
SVG
<!-- -->
<a>
<abbr>
<acronym> DEPRECATED
<address>
<applet> DEPRECATED
<article>
<aside>
<audio>
<b>
<base>
<basefont> DEPRECATED
<bdi>
<bdo>
<big> DEPRECATED
<blink> DEPRECATED
<blockquote>
<body>
<br>
<button>
<canvas>
<caption>
<center> DEPRECATED
<cite>
<code>
<col>
<colgroup>
<datalist>
<dd>
<del>
<details>
<dfn>
<dialog>
<dir> DEPRECATED
<div>
<dl>
<dt>
<em>
<embed>
<fieldset>
<figcaption>
<figure>
<font> DEPRECATED
<footer>
<form>
<frame> DEPRECATED
<frameset> DEPRECATED
<h1> – <h6>
<head>
<header>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<kbd>
<keygen> DEPRECATED
<label>
<legend>
<li>
<link>
<main>
<map>
<mark>
<menu>
<menuitem> DEPRECATED
<meta>
<meter>
<nav>
<noframes> DEPRECATED
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<param>
<pre>
<progress>
<q>
<rp>
<rt>
<ruby>
<s>
<samp>
<script>
<section>
<select>
<small>
<source>
<span>
<strike> DEPRECATED
<strong>
<style>
<sub>
<summary>
<sup>
<table>
<tbody>
<td>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<track>
<tt> DEPRECATED
<u>
<ul>
<var>
<video>
<wbr>