HTML5 Semantic Tags

Page Structure Elements

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Page Title</title> </head> <body> <header> <!-- site header / masthead --> <nav> <!-- primary navigation --> <ul><li><a href="/">Home</a></li></ul> </nav> </header> <main> <!-- unique main content --> <article> <!-- self-contained content --> <header><h1>Article Title</h1></header> <section> <!-- thematic grouping --> <h2>Section Heading</h2> <p>Content...</p> </section> <footer> <!-- article footer --> <address>By <a href="/about">Author</a></address> </footer> </article> <aside> <!-- related sidebar content --> <section>Related Articles</section> </aside> </main> <footer> <!-- site footer --> <small>© 2024 Company</small> </footer> </body> </html>

Semantic Elements Reference

ElementPurposeNotes
<header>Introductory content or navigational aidsCan appear multiple times (page + article)
<nav>Major navigation linksNot for all link groups; use aria-label to differentiate
<main>Main content; unique to the documentOne per page; skip-nav target
<article>Self-contained piece of contentBlog post, news article, forum post, widget
<section>Thematic grouping within a documentShould have a heading; not a generic container
<aside>Tangentially related contentSidebar, pull quote, advertisement area
<footer>Footer for its nearest sectioning ancestorContact, copyright, related links
<figure>/<figcaption>Self-contained figure with captionImages, code snippets, charts
<time>Machine-readable date/timeUse datetime attribute: <time datetime="2024-01-15">
<mark>Highlighted/relevant textSearch result highlighting
<details>/<summary>Expandable disclosure widgetNative accordion, no JS needed
<dialog>Native modal dialogUse showModal() for accessibility