Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-page-3] Allow custom property declarations in @page and margin rules #9150

Open
cdoublev opened this issue Aug 3, 2023 · 3 comments
Open
Labels
css-page-3 Current Work

Comments

@cdoublev
Copy link
Collaborator

cdoublev commented Aug 3, 2023

Chrome/FF (at least) allows custom properties in @page and margin rules although this is not allowed by CSS Paged Media 3. CSS Anchor Position 1 does not allow them in @try.

But I cannot think of a valid reason to exclude them.

@xiaochengh
Copy link
Contributor

xiaochengh commented Aug 15, 2023

Edit: This comment is only about @try. Made it explicit.

The current reason is that allowing custom properties in @try basically means allowing any property there, which may break anchor positioning entirely.

For example:

.target {
  position: var(--x);
  --x: absolute;
  position-fallback: --fallbacks;
}

@position-fallback --fallbacks {
  @try { --x: static; }
}

@faceless2
Copy link

Of the 8 print-focused CSS engines that support custom properties at https://printcss.live, 7 of them support them in @page. In all of those, the @page context inherits values from :root.

@cdoublev
Copy link
Collaborator Author

Thanks for both feedback.

Maybe I should have created two separate issues... I was pretty confident that it was an oversight for @try. Would it work if custom properties are accepted only if there is one or more declaration of the other accepted properties? I move this question in a separate issue.

Based on current interoperability, it seems to be required to define that they are valid in @page. I am not sure if these modifications would be enough:

  4.3. @page rule grammar

  [...]

  In addition, the following rules apply:
  
-    - The @page rule can only contain page properties and margin at-rules.
-    - The margin at-rules can only contain page-margin properties.
+    - The @page rule can only contain page and custom properties and margin at-rules.
+    - The margin at-rules can only contain page-margin and custom properties.

  [...]

  4.4. Cascading in the page context

  [...]
  
+ Custom properties inherits from '':root''.

@cdoublev cdoublev changed the title [css-anchor-position-1][css-page-3] Allow custom properties [css-page-3] Allow custom property declarations in @page and margin rules Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-page-3 Current Work
Projects
None yet
Development

No branches or pull requests

3 participants