The section
element is used to encapsulate sections of primary content and establish the
publication's structural hierarchy. Clearly grouping and identifying content enables better navigation by
anyone reading using an assistive technology (see also the faq).
An epub:type
attribute should be attached to each section
to indicate the
specific nature of the content, when applicable. See the EPUB 3 Structural Semantics Vocabulary for the list of allowed values that can be used with the
attribute.
When the epub:type
attribute is not specified, a generic section/subsection nature is assumed
based on the nesting level.
A section
must not have more than one child heading.
If a section does not have a heading, consider including an aria-label
attribute on the
section
to identify its purpose.
section
element for secondary content?No, the section
element should only be used to identify primary structural
content.
Self-contained secondary content embedded within a section — such as sidebars,
mini-articles, etc. — should be identified using the aside
and
article
elements, as appropriate.
EPUBs are typically broken up into smaller XHTML content files to improve rendering, so it's often the case that an entire part cannot be contained in a single file. The question becomes, how do you split the chapters into separate files and still retain the part?
There are two approaches you can take to flattening out your content, and neither is optimal — at least in terms of retaining the original structural hierarchy in the markup. The first is to include the part heading with the first chapter:
<body>
<section epub:type="part">
<h1>Part I</h1>
<section epub:type="chapter">
<h2>Chapter I</h2>
</section
</section>
</body>
Each subsequent chapter file would contain a single section
with an h2
heading. Although this markup approach appears to suggest that the part only contains a single
chapter, consistent heading numbering will allow an assistive technology to correctly orient the
reader.
The other approach is to separate the part heading into its own file:
<body>
<section epub:type="part">
<h1>Part I</h1>
</section>
</body>
Again, each subsequent chapter file would include an h2
heading to indicate it is
subordinate to the part. One advantage of this approach is that reading systems will render the
part heading separately from the first chapter content.
It would be nice to see a future version of EPUB include a way of retaining information about the document hierarchy regardless of how the content gets broken up into files (e.g., in the spine), but at this time no such mechanism exists.
Yes and no.
Grouping content into section
elements more clearly delineates the structure of your
document, since there's no ambiguity about where the section begins and ends (e.g., in HTML4,
headings were often interspersed throughout the content regardless of relation to structure).
This structure allows readers using assistive technologies to move from section to section more
easily.
It's also true that grouping and identifying the nature of each section
with an
epub:type
attribute aids navigation of the document at the markup level (which
is where assistive technologies usually operate).
That said, because the publication's hierarchy often gets flattened when content is split into
separate XHTML files, the section
element alone is left somewhat crippled as a
navigation aid. A reader will have more difficulty moving quickly from part to part and skipping
all the chapters in between unless they use the table of contents (i.e., each content file would
have to be loaded and each section
type checked to move forward at the markup
level).
See the Headings section for more information.