DEV Community

Cover image for Semantic HTML tags
Iz Mroen
Iz Mroen

Posted on • Updated on

Semantic HTML tags

HTML semantic tags are designed to give meaning and structure to the content of a web page, while improving accessibility and understanding of the code by developers and machines. They go beyond simply dividing the page into sections, as <div> tags do. Semantic tags help describe the role and specific content of a section of the page. Here are some of these tags:

  • <header>: Represents the header of a section or page.
  • <nav>: Used to group navigation links.
  • <main>: Encloses the main content of the page.
  • <article>: Used to define independent content that can be reused, such as a blog article.
  • <section>: Defines a generic section of a page.
  • <aside>: Used to define secondary content, often presented alongside the main content.
  • <footer>: Represents the footer of a section or page.

The benefit of using these semantic tags is that they provide structural meaning to the content, which can be beneficial for accessibility, SEO, and code maintenance. Search engines and screen readers use these tags to better understand the structure of the page.

That said, using <div> is not necessarily incorrect. Semantic tags are an additional tool to help structure content in a more meaningful way. In some cases, using <div> may still be necessary, especially when no semantic tag perfectly matches the desired structure.

In summary, using semantic HTML tags is recommended for better content structure and semantics, but that does not mean that the use of <div> is obsolete. It is important to choose tags based on the semantic meaning of the content you are trying to represent.

Top comments (1)