Semantic Tags In HTML5: The What And Why

Semantic Tags In HTML5: The What And Why


7 min read

Hello Fellow Codenewbies ๐Ÿ‘‹

a blue eye image with Stevie Wonder's quote we need to make every single thing accessible to every single person with a disability

There are many tweets and articles to raise awareness towards accessibility on web development. They are explaining the importance of thinking about accessibility first and apply things that help people with disabilities to access the web world.

I am aware of this as well, but I honestly have not applied accessibility aspects as much as I should in my projects.
I have no chance yet to squeeze in extra time to learn more about it.
But really, it should not be an excuse for not making time to learn and apply those aspects.

So lately, I do more research on accessibility aspects and do my best to apply it whenever it's needed.
One of them that I will talk about in this post is "semantic tags in HTML".

Semantic Tags In HTML5

Semantics is the study of meanings in a language
-- Cambridge Dictionary

To write semantic HTML tags means to use HTML tags that have meaning and we can interpret, even without being well explained.

For example, prior to HTML5, <b> and <i> are used to make a text bold and italic.

In HTML5, <strong> and <em> are used to achieve the same result, but with much more meaning. They add importance and emphasis to the text.

When we create a boilerplate of HTML5, we definitely will see this structure:

<!DOCTYPE html>
<html lang="en">
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />


We are seeing semantic tags in this boilerplate.

  • <html>: Encloses the whole page.
  • <head>: Contains all necessary information to render the page.
  • <body>: The contents of the page.
  • <title>: The title of the page.
  • <meta>: The metadata, to provide additional important information.

The Benefits of Semantic Tags In HTML


People with visual disabilities are depending on screen readers to use a computer and to access the web.
Semantic tags can distinguish sections and are readable for screen readers.

๐Ÿ“ Sidenotes:
I highly recommend you to watch this 4 minutes video about how screen readers work to get a picture and understand more about the importance of semantic tags and how they benefit people with visual disability.

Lighter and maintainable code

Light and clear codes are easier to maintain because they are easier to read.
Let's see below example without semantic tags:

   <p><b>Cheese Kingdom</b></p>
   <p>Some recipes with cheese:</p>
     <p>1. Cheese burger</p>
         - Cheese
         - Burger's bread
         - Beef burger
    <p>2. Mac and cheese</p>
        - Cheese
        - Macaroni
        - Roasted Chicken

And with semantic tags:

    <h1>Cheese Kingdom</h1>
    <p>Some recipes with cheese:</p>
      <li>Cheese burger
          <li>Burger's bread</li>
          <li>Beef burger</li>
      <li>Mac and cheese
          <li>Roasted Chicken</li>

Which one is easier to read and to interpret?
I believe you've known the answer ๐Ÿ˜Š

Search Engine Optimization (SEO)

Semantic tags help in providing richer information for search engines.
When search engines cannot read a website properly, then the website cannot be ranked properly. This can cause bad performance and lower its chance to reach a bigger audience.

There are many semantic tags in HTML5. But the most popular ones are:

  • <h1> - <h6>: For headings in a page.
  • <p>: For paragraphs.
  • <img>: For images.
  • <ul>, <ol>, <li>: For unordered & order lists.
  • <form>: For forms.
  • <input>: For inputs.
  • <table>: For tables.
    • <thead>: For the header of a table.
    • <tbody>: For the body of a table.
    • <tfoot>: For the footer of a table.

Structured Semantic Tags HTML5

In a webpage, we usually see a structure of a header, body of the page, a footer, and sometimes also sidebars.


  • <header>
    The header of a page. Navigation is usually included in the header.
  • <nav>
    For navigation bar.
  • <main>
    For the dominant content in a page, including <article> and <section>. There should be only one main tag on a page.
  • <article>
    For articles, like blog posts.
  • <section>
    For breaking down an article into sections. It can help users to find what they're looking for in an article.
  • <aside>
    A tag that focuses on less important (secondary) content such as sidebars.
  • <footer>
    The footer of a page. It might include navigation.

I provide a playground on Codepen below as an example.


We learned that using semantic tags in HTML5 benefits everybody and is very important for accessibility, maintaining larger and cleaner codes, and also powerful for a webpage's performance in SEO.
Therefore, we better start to learn and use the correct semantic tags from now on.

Did you find this article valuable?

Support Ayu Adiati by becoming a sponsor. Any amount is appreciated!