Semantic HTML: Top 20 Elements and How to Use Them

Master the semantic HTML elements with this in-depth guide. Packed with detailed explanations and practical examples to help you use each element correctly.

Welcome to the exciting world of Semantic HTML! In this article, we will explore the top 20 elements that form the foundation of web development. Whether you're a fresh grad or someone looking to enhance their web development skills, this guide is designed to help you understand the importance of semantic HTML and how to use it effectively in your projects. We'll provide plenty of code examples and explain each concept in a beginner-friendly way.

You might be wondering:

  • What are all these new semantic elements in HTML5?
  • When should I use each one?
  • How do they differ from regular divs?

This comprehensive guide will answer all those questions and more! You'll learn the top 20 semantic HTML elements with detailed explanations, real-world examples, and handy tips.

Let's level up your markup skills!

The Importance of Semantics

Before we jump into the elements, let's briefly discuss why semantic HTML matters:

  • Accessibility: It provides meaning to assistive technologies like screen readers.
  • SEO: Search engines understand semantic code better.
  • Maintainability: The code is easier to read and edit later.

Ready to start writing more meaningful HTML? Let's go!


The <header> element represents introductory content like navigation, headings, logos etc.

  <h1>My Website</h1>
    <!-- nav links -->

Tip: Only one <header> per page, usually at the top.


The <nav> element contains major navigation links on your site:

    <li><a href="/">Home</a></li>
    <li><a href="/about">About</a></li>
    <li><a href="/contact">Contact</a></li>

Tip: Screen readers use <nav> to determine page navigation.


The <main> element wraps the central content unique to each document or app screen:

  <p>Home page content goes here...</p>

Tip: Use just one <main> per page. Don't nest it inside other elements.

Still with me? Let's keep going and look at a few more important elements...


The <section> element divides content into thematic groups:

  <!-- news content -->

  <!-- products -->

Tip: Multiple <section>s are common on one page.


The <article> element encloses independent, self-contained content like a forum post, blog entry, or news story:

  <h2>My Blog Post</h2>
  <p>Post contents...</p>

Tip: <article> is meant for content that can stand alone, separate from the page.


The <aside> element holds content related to surrounding content, like sidebars, pullquotes, glossary terms, related posts etc.

  <!-- related content -->

Tip: <aside> gives additional info about main content; it doesn't stand alone.


The <footer> element represents concluding content like copyright, contact info, sitemaps, etc:

  Copyright © 2022 MyWebsite

Tip: Usually one <footer> per page at the bottom, but not required.

We've covered the big semantic block elements. Now let's look at some semantic inline/text elements...


The <strong> element indicates text of strong importance. Screen readers emphasize it:

<p>This sauce is <strong>extremely hot</strong>.</p> 

Tip: Use <strong> to highlight key words and phrases.


The <em> element stress emphasis on text:

<p>I <em>love</em> semantic HTML!</p>

Tip: <em> implies vocal stress when reading aloud.


The <blockquote> element indicates a long quotation:

  <p>Semantic HTML is the heart of accessible, optimized web pages.</p>

Tip: Always cite the source URL!


The <q> element is for shorter quotations that don't require paragraph breaks:

<p>As Denis said: <q>Code is poetry</q></p>

Tip: Browsers add quotation marks around <q> automatically.


The <cite> element is used for citations and references like book/paper titles:

<p>Read more in <cite>Semantic HTML: A History</cite></p>


The <dfn> element indicates the defining instance of a term:

<p><dfn>Semantics</dfn> means the meaning of code structure.</p>

Tip: <dfn> helps distinguish definition of key terms.


The <abbr> element represents an abbreviation or acronym:

<p>I love <abbr title="HyperText Markup Language">HTML</abbr>!</p>

Tip: The title attribute provides the full expansion.

Almost there! Just a few more elements to cover.


The <time> element denotes times and dates like events, publication dates, etc:

<time datetime="2022-01-01">January 1, 2022</time>

Tip: Use the datetime attribute to specify standard format.


The <address> element provides contact info for author/organization:

  <a href=""></a>

Tip: Can include street addresses too!

17.<figure> and <figcaption>

<figure> represents self-contained content like images or code snippets. <figcaption> provides a caption:

  <img src="html.png" alt="HTML code screenshot">
  <figcaption>Code sample</figcaption>


The <mark> element highlights relevant text:

<p>Do not forget to use <mark>semantic markup</mark>!</p>

Tip: <mark> is different from <strong>. It indicates relevance vs importance.

19.<details> and <summary>

<details> creates an expandable/collapsible disclosure widget. <summary> provides visible heading:

  <summary>Read more</summary>
  <p>Additional details...</p>

20.<meter> and <progress>

The <meter> and <progress> elements represent numeric values in a range:

<meter value="0.5">50%</meter>

<progress value="70" max="100">70%</progress> 

There you have it! The top 20 semantic HTML elements and how to use them. With this guide under your belt, you can write meaningful markup that improves accessibility, SEO, and maintainability.

Complete HTML Structure

Here is an example HTML code snippet to demonstrate usage of all the semantic elements covered in this article:

<!DOCTYPE html>
  <title>Semantic HTML Elements Example</title>


  <h1>My Website</h1>
      <li><a href="/">Home</a></li>
      <li><a href="/about">About</a></li>
      <li><a href="/contact">Contact</a></li> 


    <h2>Article Title</h2>
    <p>Lorem ipsum dolor sit amet, <a href="#">consectetur</a> adipiscing elit. Praesent ac magna sed neque sodales varius et id lacus. Sed quis erat est.</p>

    <p>As Denis said: <q>Code is poetry</q></p>

      <img src="image.jpg" alt="Article image">
      <figcaption>Image caption</figcaption> 


      <li><a href="#">Related post 1</a></li>
      <li><a href="#">Related post 2</a></li>


  <p>Copyright © 2023 My Website</p>


This demonstrates proper usage of <header>, <nav>, <main>, <article>, <aside>, <footer>, <figure>, <figcaption>, <q> and other semantic elements covered in the article. The snippet can serve as a handy reference for beginners.

Now it's time to put your skills into practice! Try incorporating more semantic elements into your next web project.

Let me know if you have any other questions. Happy coding!

Subscribe to JS Dev Journal

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.