> For the complete documentation index, see [llms.txt](https://docs.typeset.sh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.typeset.sh/setup/css-and-paged-media/page-groups.md).

# Page groups

Using named pages and page selectors you can create so called page groups.&#x20;

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.

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

section.chapter {
    page: chapter;
}
```

{% embed url="<https://typeset.sh/en/live-demo/page-groups>" %}

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