学习库HTMLSemantic Page Structure

Semantic Page Structure

Turn anonymous containers into a page people and machines can navigate.

更新于 适用于 HTML Living Standard

Semantic elements explain why a region exists. They create landmarks for assistive technology and keep the document understandable even before CSS loads.

Name the major regions

page.html
<header>
  <a href="/">Arcbyte</a>
  <nav aria-label="Primary"><a href="/courses">Courses</a></nav>
</header>
<main>
  <article>
    <h1>Semantic HTML</h1>
    <p>A lesson with an independent topic.</p>
  </article>
  <aside aria-label="Related lessons">...</aside>
</main>
<footer>© Arcbyte</footer>

Most pages need one main. nav is for major navigation groups, article for independently meaningful content, section for a themed region with a heading, and aside for supporting content.

Use a div when meaning is absent

div and span are neutral containers. They are useful for styling hooks and layout groups when no semantic element fits.

Anonymous
html
<div class="navigation">...</div>
<div class="main">...</div>
Meaningful
html
<nav aria-label="Primary">...</nav>
<main>...</main>

Prefer native elements

A clickable div is not a button. Recreating focus, keyboard activation, disabled behavior, and semantics is difficult and unnecessary.

actions.html
<button type="button">Save progress</button>
<a href="/next-lesson">Next lesson</a>

Keep this

Choose landmarks and content elements by purpose, keep one clear main, and use neutral containers only when no meaningful element applies.

学习位置已保存在此设备上。