Page groups

Using named pages and page selectors you can create so called page groups.

If you have a document with multiple chapters that span several pages and you want to select only the first page of each chapter, you can do so by enclosing each chapter in its own element and forcing a named page (e.g. chapter). You can then use the nth() selector to select the first page of all chapters.

@page :nth(1 of chapter) {
    background: lightgrey;
}

section.chapter {
    page: chapter;
}

See https://www.w3.org/TR/css-gcpm-3/#document-sequence-selectors

Last updated