Re: [csswg-drafts] [css-page-3] Should `@page` declarations be hoisted? (#11272)

It doesn't matter for the behavior. Note that the spec recommends that `@page` declaration be placed before any margin rules, though.

https://drafts.csswg.org/css-page-3/#margin-at-rules

> Page-margin boxes are created by [margin at-rules](https://drafts.csswg.org/css-page-3/#margin-at-rule) inside the [page context](https://drafts.csswg.org/css-page-3/#page-context). Authors should put these rules after any declarations in the page context as legacy clients may not handle declarations after margin at-rules correctly.

As such, it makes slightly more sense to hoist, than not to hoist. But it shouldn't matter. Specificity isn't an issue here, since what's in `@page` and what's in `@top-left` addresses different boxes (page box vs. page margin box).

`@page` properties apply in the `page context`, which acts as a parent of any `page margin contexts` (which are defined by property declarations inside page margin rules). A page margin context may inherit properties from a page context, which in turn may inherit from the document root element.

See https://drafts.csswg.org/css-page-3/#page-model and https://drafts.csswg.org/css-page-3/#page-properties

-- 
GitHub Notification of comment by mstensho
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11272#issuecomment-2591040665 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 14 January 2025 20:28:17 UTC