Unlike other HTML5 elements such as
nav, it’s never been particularly clear to me when is appropriate to use
section. This is due in large part to many experts having expressed that it doesn’t quite work as intended.
If you’re not sure whether to use a
<section>, it’s probably best to avoid it. It’s much more important that you create a sound document outline.
Relatedly: don’t let the original intended use of
section tempt you to put multiple H1s on a page in the vain hope that browsers and assistive technology will interpret their nesting level to handle hierarchy appropriately. That would rely on on a document outline algorithm but no browser implements document outlining.
One sensible application of
section is to provide additional information to screen reader users about the semantic difference between two adjoining content areas, when that distinction is otherwise only being made visually with CSS.
Here’s an example. Smashing Magazine’s blog articles begin with a quick summary, followed by a horizontal line separating the summary from the article proper. But the separator is purely decorative, so if the summary were wrapped in a
div then a screen reader user wouldn’t know where it ends and the article begins. However by instead wrapping the summary in
<section aria-label="quick summary">:
- our wrapper has the built-in ARIA role of
regionis a type of generic landmark element, and as a landmark a screen reader user will find it listed in a summary of the page and can navigate to it easily.
- by giving it an accessible name (here via
aria-label) it will be announced by a screen reader, with “Quick summary region” before and “Quick summary region end” after.