CodeToLive

HTML Semantic Elements

Semantic elements clearly describe their meaning to both the browser and the developer. They make the structure of a web page more meaningful and accessible.

Why Use Semantic Elements?

Common Semantic Elements

Example: Semantic HTML Structure


<header>
  <h1>Website Title</h1>
  <nav>
    <a href="#">Home</a>
    <a href="#">About</a>
  </nav>
</header>

<main>
  <article>
    <h2>Article Title</h2>
    <p>This is the content of the article.</p>
  </article>

  <section>
    <h2>Section Title</h2>
    <p>This is a standalone section.</p>
  </section>
</main>

<footer>
  <p>© 2025 CodeToLive</p>
</footer>
      

Non-Semantic Elements

Non-semantic elements like <div> and <span> do not convey any meaning about their content. They are often used for styling purposes.


<div class="container">
  <span class="highlight">This is a non-semantic example.</span>
</div>
      
Next: HTML Multimedia