Skip to content

safe-printable-inset META value proposal#233

Open
mstensho wants to merge 5 commits intoweb-platform-tests:mainfrom
mstensho:mstensho/safe-printable-inset
Open

safe-printable-inset META value proposal#233
mstensho wants to merge 5 commits intoweb-platform-tests:mainfrom
mstensho:mstensho/safe-printable-inset

Conversation

@mstensho
Copy link
Copy Markdown

@mstensho mstensho commented Jan 8, 2026

@mstensho mstensho marked this pull request as ready for review January 15, 2026 08:48
Copy link
Copy Markdown
Contributor

@jcscottiii jcscottiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I only have one question.


where `inset-specifier` is a numeric value. The unit could be CSS pixels or
points. Using centimeters for anything here isn't a great idea, since they don't
convert nicely into CSS pixels (unlike inches). I suggest using CSS pixels.
Copy link
Copy Markdown
Contributor

@jcscottiii jcscottiii Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Is it worth it to enforce the usage of pixels here? (Or rather what's the risk if we don't enforce it?)

When new metadata is introduced, there's a risk of incorrect usage (e.g., typos, invalid values, or inappropriate units). For example, a value like content="2in" might be provided, even though the RFC suggests CSS pixels or points and discourages inches. The best way to mitigate this is to add automated checks. Other places that handled something similar:

  • RFC 163 (web_features) added a lint to ensure its new metadata didn't get out of sync with test files
  • RFC 158 (Variant name should be a non-zero length string) added a lint to forbid a problematic authoring pattern
  • RFC 211 (Support testdriver.js in other test types) proposed a lint to enforce correct usage with reftest-wait.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking a unitless value, which is why I'm suggesting pixels. But I suppose we could require units (and even allow centimeters, for all those rounding error fans out there) to be specified as part of the value instead?

Copy link
Copy Markdown
Member

@gsnedders gsnedders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly my question is "how would we hook this up to the style engine", because somehow we have to go from the meta element to this impacting print style and output.

Most of the time we're using WebDriver to communicate with the browser; does it therefore make sense to add something to the WebDriver print command that specifies the safe printable inset? My gut is yes?

@mstensho
Copy link
Copy Markdown
Author

Here's something I hacked together for testing.

https://chromium-review.googlesource.com/c/chromium/src/+/7415241

Does this answer your question?

@mstensho
Copy link
Copy Markdown
Author

mstensho commented Feb 3, 2026

@gsnedders Are you asking whether we should add something to https://w3c.github.io/webdriver/#print-page ? I think that might be a good idea. It could be specified as a single inset value, or it could be a rectangle within pageWidth x pageHeight.

Is everything in centimeters here? That's rather bad, since they don't convert nicely to CSS pixels. But I suppose we need to follow suit.

Copy link
Copy Markdown
Member

@gsnedders gsnedders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gsnedders Are you asking whether we should add something to https://w3c.github.io/webdriver/#print-page ?

Yes, which appears to be what the draft CL does. Can you please make a PR against WebDriver, and get consensus there first?

I think that might be a good idea. It could be specified as a single inset value, or it could be a rectangle within pageWidth x pageHeight.

It should allow both separately, I'd expect.

Is everything in centimeters here? That's rather bad, since they don't convert nicely to CSS pixels. But I suppose we need to follow suit.

Yes, which is… deeply unfortunate, I agree. Though to be fair, A4 paper doesn't convert nicely to CSS pixels either. :)

@mstensho
Copy link
Copy Markdown
Author

mstensho commented Feb 4, 2026

@gsnedders Are you asking whether we should add something to https://w3c.github.io/webdriver/#print-page ?

Yes, which appears to be what the draft CL does. Can you please make a PR against WebDriver, and get consensus there first?

What's the name of the repo?

I think that might be a good idea. It could be specified as a single inset value, or it could be a rectangle within pageWidth x pageHeight.

It should allow both separately, I'd expect.

I really think one of them should be enough. But that can be discussed there.

Is everything in centimeters here? That's rather bad, since they don't convert nicely to CSS pixels. But I suppose we need to follow suit.

Yes, which is… deeply unfortunate, I agree. Though to be fair, A4 paper doesn't convert nicely to CSS pixels either. :)

Hey, A4 doesn't even convert nicely to centimeters. The height being 21cm * sqrt(2). :-p

mstensho added a commit to web-platform-tests/wpt that referenced this pull request Feb 25, 2026
For print reftests, check <meta name="safe-printable-inset"> to simulate
an unprintable region along the paper edges. The `content` attribute
takes a non-negative number, which is the safe printable inset specified
in centimeters.

Only implemented for executorwebdriver.

Spec discussion: w3c/csswg-drafts#11395
Spec change: w3c/csswg-drafts#13190
RFC: web-platform-tests/rfcs#233

For background, see https://drafts.csswg.org/css-page-3/#printable-area
@mstensho
Copy link
Copy Markdown
Author

wptrunner and webdriver code changes PR here: web-platform-tests/wpt#58030

mstensho added a commit to mstensho/webdriver that referenced this pull request Feb 25, 2026
This is for testing the `page-margin-safety` descriptor in `@page` and
page margin box contexts.

Spec discussion: w3c/csswg-drafts#11395
Spec change: w3c/csswg-drafts#13190
RFC: web-platform-tests/rfcs#233

wptrunner and webdriver code changes:
web-platform-tests/wpt#58030
@mstensho
Copy link
Copy Markdown
Author

webdriver spec change: w3c/webdriver#1950

@mstensho
Copy link
Copy Markdown
Author

mstensho commented Mar 4, 2026

The css-page spec changes have landed, and I've updated the description here accordingly.

@mstensho
Copy link
Copy Markdown
Author

mstensho commented Mar 9, 2026

Updated the RFC to use centimeters.

Please have another look.

Thank you.

@mstensho
Copy link
Copy Markdown
Author

mstensho commented Apr 7, 2026

I went with a single value for all four edges for now. As pointed out in the spec, the browser usually cannot make assumptions about which edge ends up where.
Can this be reviewed now?

@mstensho mstensho requested a review from gsnedders April 7, 2026 06:22
@jcscottiii
Copy link
Copy Markdown
Contributor

We talked about this today. @gsnedders is commenting on w3c/webdriver#1950 and w3c/csswg-drafts#11395

Comment on lines +28 to +35
Why just one value for all four edges? Although many printers indeed don't
necessarily have a uniform unprintable area width along each of the four paper
edges (although many do), so that just providing one value for all is an
oversimplification of reality, printers may rotate the print output at their own
discretion. The user agent may therefore not be able to make assumptions about
which edge (long or short?) will be fed first into the printer, or what
orientation the sheet of paper has. Therefore using just one value (which should
represent the larger of the four) seems reasonable.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does leave us unable to test all the different at-rules the descriptor applies to — @page, @top-left-corner, @top-left, @top-center, @top-right, @top-right-corner, @right-top, @right-middle, @right-bottom, @bottom-right-corner, @bottom-right, @bottom-center, @bottom-left, @bottom-left-corner, @left-bottom, @left-middle, @left-top.

The spec says, along these lines:

Some printers don’t have a uniform unprintable area width along each of the four paper edges, and the printer may rotate the print output at their own discretion. The user agent may therefore not be able to make assumptions about which edge will be fed first into the printer, or what orientation the sheet of paper has. If the user agent cannot make such assumptions, only one will be provided (to be used on all 4 sides): The larger of these four values. Otherwise, if the user agent can trust that the four values are usable individually, and that no rotation is going to take place, and so on, each side of the page may have individual values.

It's not entirely clear to me from the spec how you go from potentially seventeen values (if specified in @page and all the margin at-rules) to only one, because the "larger of these four values" makes an assumption that you've already gone from seventeen to four.

Maybe starting with taking a single value is fine — but I could easily see us wanting to extend the metadata to take four values (potentially with semantics similar to the margin property?) to be able to actually test the case where the user agent can make assumptions about what edge will be fed first.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not unable to test any of those at-rules. The safe printable inset will just be the same along each of the four edges.

@page is adjacent to all four edges of a paper sheet, so all of margin-top, margin-right, margin-bottom and margin-left may be affected by page margin safety. @blah-corner is adjacent to two of the edges. The remaining at-rules are adjacent to only one edge. For e.g. @top-center, only margin-top may be affected by page margin safety. For @bottom-right-corner, margin-right and margin-bottom may be affected.

Here's a test (not yet landed): https://chromium-review.googlesource.com/c/chromium/src/+/7415846/4/third_party/blink/web_tests/external/wpt/css/css-page/safe-printable-inset-003-print.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants