# 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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.typeset.sh/setup/css-and-paged-media/page-groups.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
