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-syntax-3] Descriptor declarations with global substitution value, CSS-wide keyword, !important #7838

Open
cdoublev opened this issue Oct 6, 2022 · 3 comments

Comments

@cdoublev
Copy link
Collaborator

cdoublev commented Oct 6, 2022

Within a <style-block> or <declaration-list>, !important is automatically invalid on any descriptors. If the rule accepts properties, the spec for the rule must define whether the properties interact with the cascade, and with what specificity. If they don’t interact with the cascade, properties containing !important are automatically invalid; otherwise using !important is valid and causes the declaration to be important for the purposes of the cascade.

According to #5969 (comment), all declarations in @page are for descriptors. Therefore I assume the above (from CSS Syntax) also applies to descriptors matching a property. If so, the first sentence seems confusing to me.

Declarations in page and margin contexts cascade just like declarations in style rule for elements.

https://w3c.github.io/csswg-drafts/css-page-3/#cascading-and-page-context

@fantasai
Copy link
Collaborator

fantasai commented Nov 16, 2022

Hmm, this seems to me like terminology just failing to link up correctly. Syntax seems to think the declarations inside @page are properties, and Page thinks they're descriptors.

I'm not sure yet what edits we need, but clearly we need some edits. :)

@cdoublev
Copy link
Collaborator Author

cdoublev commented Nov 17, 2022

Yeah, imo, descriptors matching a property should be defined as functionnaly equivalent to properties, ie. their declarations cascade if the spec for the rules accepting them defines it, and they should also allow substitution values and CSS-wide keywords, like in keyframe rules (in which declarations do not cascade though), noting that currently @page and margin rules only accept inherit though.

@cdoublev
Copy link
Collaborator Author

cdoublev commented Nov 19, 2022

Changing the title to broaden the topic because it is also unclear if descriptor declarations accept global substitution values (like var() or attr()) and CSS-wide keywords. Below, Chrome/FF accept them in some cases:

  • declarations for font-display are all parsed as invalid
  • declarations for size are all parsed as valid
  • declarations for color are all parsed as valid
@font-face { 
  font-display: block !important; 
}
@font-face { 
  font-display: initial; 
}
@font-face { 
  font-display: var(--custom); 
}
@page { 
  color: green !important; 
  size: 1px !important; 
}
@page { 
  color: initial; 
  size: initial; 
}
@page { 
  color: var(--custom); 
  size: var(--custom); 
}

The value of a custom property can be substituted into the value of another property with the var() function.

https://drafts.csswg.org/css-variables-1/#using-variables

Several CSS-wide property values are defined below; declaring a property to have these values explicitly specifies a particular defaulting behavior. As specified in CSS Values and Units [css-values-3], all CSS properties can accept these values.

https://drafts.csswg.org/css-cascade-5/#defaulting-keywords

In my opinion:

  • all CSS-wide keywords and var() should be valid if declarations cascade, for all types of descriptors, otherwise they are invalid
  • substitution values other than var() should be invalid for all type of descriptors

@cdoublev cdoublev changed the title [css-syntax-3] Allow a descriptor matching a property to cascade and get a priority [css-syntax-3] Descriptor declarations with custom variable, CSS-wide keyword, !important Nov 19, 2022
@cdoublev cdoublev changed the title [css-syntax-3] Descriptor declarations with custom variable, CSS-wide keyword, !important [css-syntax-3] Descriptor declarations with global substitution value, CSS-wide keyword, !important Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants