- From: Guillaume Ayoub via GitHub <noreply@w3.org>
- Date: Sat, 14 Mar 2026 13:10:37 +0000
- To: public-css-archive@w3.org
While finally implementing viewport units in WeasyPrint, I found this issue. That was very useful, thanks for all the comments!
Here’s some feedback.
> I would like to propose the page viewport-percentage length units, pvw, pvh, pvi, pvb, pvmin, pvmax. These units should be same as normal vw, vh, vi, vb, vmin, vmax in non-paged media context.
We added these units too, and we like the idea.
> +1 to [@markbrown](https://github.com/markbrown)'s comment - the first page cannot reliably be resolved without at least some layout, so resolving against the vw/vh from the generic `@page` rule will be far easier to implement.
> While we currently use the first page in our implementation we agree that it would be best to use a virtual page computed from the `@page` rules without selectors of any kind. For easier discussion we suggest naming that virtual page. We suggest "_base page_".
We actually followed the opposite path. We first tried to use the base page (cool name), that looked much easier. But it required so many features (percentages, font-relative units, variables, inheritance from root element…) that we ended up using the same code as real pages. At this point, there was no advantage creating a fake, abstract base page, and using the first page was actually easier.
> To avoid cyclical dependencies for `vw` units in `@page` rules (at least for `size`, `margin`, `border-width` and `padding`) we'd prefer to handle this at the point of resolving the units, either using a fixed reference size or per-property fixed results, independent of the number. Either of those could be based on common values or intentionally noticeable ones. For simplicity this should affect all values in `@page` rules, regardless of their properties.
I agree with the idea of breaking cyclical dependencies when resolving units. It avoids different validation rules for `@page` rules and for properties elsewhere. It may also apply for media queries, and even for font-relative units everywhere. We used this strategy in WeasyPrint for viewport units, using the default page size (unspecified, A4 in WeasyPrint) for all units resolved before the first page creation during the layout.
A side effect is that viewport units in `@page` use the fallback for the first page, but the real value for other pages. It’s pretty interesting in cases like:
```css
@page large {
size: 200pvw 200pvh;
}
```
However, it’s strange for:
```css
@page {
size: 200pvw 200pvh;
}
```
where the first page has the fallback size (A4), and all the other pages are larger than the first page (A2).
--
GitHub Notification of comment by liZe
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5437#issuecomment-4060530100 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Saturday, 14 March 2026 13:10:37 UTC