HTML5 Semantic Tags

Syed Muhammad Ali Raza - Aug 17 '23 - - Dev Community

Unlock the power of HTML5 semantic tags: Improve structure and accessibility

HTML5 revolutionized web development by introducing a set of semantic tags that went beyond presentation. the "semantic" tag, this tag offers a richer and more meaningful way to structure content on web pages. In this article, we will look at HTML5 semantic tags, understand their importance, and provide practical insight into their implementation.

Understanding tag semantics

Semantic tags are designed to reflect the meaning and structure of the content they contain. Unlike non-semantic tags like div and span, which primarily serve design and layout purposes, semantic tags provide developers and browsers with a better understanding of content intent.

1. header

The "header" tag represents the opening part of a web page, which usually includes the site logo, navigation menu, and other elements that appear above. These tags provide a semantic overlay for these elements, helping with accessibility and SEO.

<header>
    <h1>My Website</h1>
    <nav>
        <ul>
            <li> <a href="#">Home</a> </li>
            <li> <a href="#"> About </a> </li>
            <li> <a href="#">Communication</a> </li>
        </ul>
    </nav>
</header>
Enter fullscreen mode Exit fullscreen mode

2. nav

The "nav" tag defines the part of the navigation link that directs the user through different pages or sections of a web page. By using this tag, you expressly indicate that the enclosed content is for navigational purposes.

<nav>
    <ul>
        <li> <a href="#">Home</a> </li>
        <li> <a href="#">Service</a> </li>
        <li> <a href="#">Portfolio</a> </li>
    </ul>
</nav>
Enter fullscreen mode Exit fullscreen mode

3. main

The "Main" tag defines the main content of the web page, helping screen readers and search engines focus on key information. This is especially useful for making your content more accessible and structurally sound.

<main>
    <h1>Welcome to our blog</h1>
    <article>
        <h2>Article title</h2>
        <p>This article is about... </p>
    </article>
</main>
Enter fullscreen mode Exit fullscreen mode

4. article

The "article" tag represents standalone content that can be distributed independently, such as a blog post or news article. These tags are very important to organize your content and improve your SEO.

<article>
    <h2>Article title</h2>
    <p>This article is about... </p>
</article>
Enter fullscreen mode Exit fullscreen mode

5. section

The "Section" tag defines a thematic group of content, helping to logically organize your site. These tags improve accessibility and search engine indexing by making content more meaningful.

<section>
    <h2>About Us</h2>
    <p>We are a passionate team... </p>
</section>
Enter fullscreen mode Exit fullscreen mode

6. footer

The "footer" tag refers to the summary section of a website, which often includes copyright information, contact information, and links to related resources. It provides a semantic container for elements.

<footer>
    <p> © 2023 My Website. All rights reserved. </p>
    <nav>
        <ul>
            <li> <a href="#">Privacy Policy</a> </li>
            <li> <a href="#">Terms of Service</a> </li>
        </ul>
    </nav>
</footer>
Enter fullscreen mode Exit fullscreen mode

The results

HTML5 semantic markup provides a more intuitive and meaningful way to structure web content. By using these tags, you not only increase the accessibility and SEO-friendliness of your website, but also create a more coherent and understandable structure for developers and browsers. When you add semantic tags to your project, you contribute to a web that is not only pleasing to the eye, but more optimized for search engines and assistive technologies. Embrace the power of semantic tags and watch your web development flourish!

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .