- From: Morten Stenshorne via GitHub <noreply@w3.org>
- Date: Thu, 23 Oct 2025 08:38:07 +0000
- To: public-css-archive@w3.org
Here is what I propose:
Add a property / descriptor (the spec seems confused about this terminology) for `@page` and `@page` margin boxes:
Name: `page-margin-safety`
Value: `none` | `clamp` | `add`
Initial: `none`
The spec text could be something like:
> Most printers have a small region along each edge of the page sheet which is unprintable, typically due to the printer's paper handling mechanism. See https://drafts.csswg.org/css-page-3/#page-terms
>
> `page-margin-safety` can be used to make sure everything ends up within the printable area, by adjusting the page margins.
>
> Some printers don't have a uniform unprintable area width along each of the four paper edges, and may rotate the print output at their own discretion. The user agent cannot make assumptions about which edge will be fed first into the printer, or what orientation the sheet of paper has. Therefore, only one value can be reliably provided here: The larger of these four values.
>
> Let this value be `<safe-printable-inset>`, which is a `<length>`.
>
> If `page-margin-safety` is `none`, this value has no effect. If it is `clamp`, the used margin values on each side will be the maximum of computed value and `<safe-printable-inset>`. If it is `add`, the used margin values will be computed value plus `<safe-printable-inset>`.
>
> `page-margin-safety` only affects margins that are adjacent to a page's edges. In other words, when `page-margin-safety` is specified in a margin context, it will only have an effect at one or two sides. For instance, `@page { @top-right-corner { page-margin-safety: clamp; } }` may only clamp top and right margin values, as the bottom and left margins face the document's contents, not the page's edges.
`page-margin-safety` could also be seen as a possible shorthand for `page-margin-safety-top`, `page-margin-safety-right`, `page-margin-safety-bottom`, and `page-margin-safety-left` (+ the logical properties too), just like `margin` is a shorthand. But I suggest that we wait with this.
Also add a shorthand property `page-safe-margin` that maps to `margin`, but only if in a context where `page-margin-safety` applies. This is mainly for feature detection.
Name: `page-safe-margin`
Value: <'margin-top'>{1,4}
Initial: `auto`
Unless its value is the initial one (`auto`), it will set `margin` to the specified value. This should be done parse-time. Hmm.. rather than shadowing `auto`, maybe we should we allow a `none` value, and have that as initial?
The `page-margin-safety` shorthand could also reset `page-margin-safety` to `clamp`. I think that would make sense.
Example:
```css
@page {
margin: 1cm; /* Will only be used if the feature isn't supported */
page-safe-margin: 7px 0; /* Set margin to "7px 0" if page-margin-safety is supported */
page-margin-safety: clamp;
}
```
Feedback appreciated.
--
GitHub Notification of comment by mstensho
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11395#issuecomment-3435760484 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 23 October 2025 08:38:07 UTC