The custom classes
book.css has a built-in feature that automatically assigns numbers to chapters,
sections, or subsections without manual intervention. Let's show how to do it!
Add the following classes into your document, and book.css does the rest:
chapter
ssection
subssection
Example of use:
<section class="chapter">
<h1> Chapter title </h1>
<section class="ssection">
<h2> Section title </h2>
<section class="subssection">
<h3> Sub-Section title </h3>
<section>
<section>
<section>
The <section> element is used here instead of the nonsensical
<div>. Both will be displayed the same way, but screen readers interpret
a section in a more appropriate manner, unlike a div!
The <section> element in HTML is semantic and indicates a thematic grouping of content,
making it useful for screen readers to understand the structure and context of the content.
This can assist users who rely on screen readers to navigate and understand web pages more
effectively. It is then perfectly suitable to indicate the chapters and sections. Fot the
h3 level, the section can effectively be replaced by article.
Notice that a proper semantic markup, including correct usage of "section", "article",
"header", "footer", etc., can significantly enhance accessibility for users of assistive
technologies like screen readers.
Table of Contents navigation
book.css provides a fixed side navigation panel styled with the class
book-toc. Its width is controlled by the --toc-width
variable (default 0; set it to something like 16rem
to reveal the panel). The body left margin adjusts automatically via
margin-left: var(--toc-width) on html.
The minimal HTML structure for a side ToC panel is:
<nav class="book-toc" aria-label="Table of contents">
<h1>Document title</h1>
<ul id="toc"></ul>
</nav>
The list can be filled manually, or automatically from the document headings
using the Wexa.Book JavaScript class — see
autotoc.html for a live demonstration.
Coexistence with menu.css. Since version 3.0, all base nav
resets in menu.css are scoped to nav.nav-wexa.
Loading both menu.css and book.css on the same page
(as this page does) is therefore safe: the ToC nav.book-toc
element is unaffected by the menu reset rules.