Re: [csswg-drafts] [css-page][css-env] Expose unprintable areas via CSS (#11395)

I have some concerns (whose strength I'm going back and forth on) about how useful this is, in the face of `@page { size :...}` mismatches potentially causing promised-to-be-"safe" margins to be scaled down and made unsafe.  (Some discussion in second half of https://github.com/mozilla/standards-positions/issues/1258#issuecomment-3003424374 - I proposed there that we magically correct for this by doing a `@page`-size-based adjustment to the value of the variable itself, but @mstensho correctly pointed out that this creates circular dependencies, so we can't really correctfor this in that way.)

It occurs to me that one way to avoid those circular dependencies would be to just make this a flag instead of an `env`, e.g.
```
@page {
  margin: 0.5;
/* This will increase the `margin` on any side(s) where the "safe margin"
is larger than what the author specified above. This could even take different
values like `pad` vs `clamp` to control whether it gets added to the `margin`
vs. gets treated as a lower-bound for the `margin`, if we want that level of
expressiveness. */
  enforce-safe-margins: auto;
}
```

@mstensho what do you think?  This has the desired effect of avoiding clipping (

Notably, this is less expressive than the proposal here in several ways -- but I think that reduced-expressiveness might not be useful/necessary anyway? In particular:
* This alternate proposal doesn't allow you to do arithmetic (e.g. adding or subtracting a bit from the safe margin).  (Though you can still get a similar effect by e.g. adding CSS margins in your content if your really want to;  and/or we could have `enforce-safe-margins: pad` to specify that they "stack" on top of the specified margins rather than serving as a lower-bound.)
* This alternate proposal doesn't let you toggle the safe margin separately per-side (though of course we could extend it to do so, e.g. `enforce-safe-margins: auto auto auto none` or something).  I'm not sure that it's useful to do that, though?  I don't know that authors are going to want to say "Please enforce safe margins for these 3 sides but allow clipping on this one".

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


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

Received on Wednesday, 2 July 2025 15:31:24 UTC