Skip to content

Refine CSS Value Processing document #40546

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sakupi01
Copy link

@sakupi01 sakupi01 commented Jul 27, 2025

Description

The change mainly aims for better accuracy to describe CSS value processing flow according to the specification.

Motivation

The previous version sometimes used incorrect terminology and descriptions, which will ultimately lead differences between mdn and the specs.

e.g.

  • CSS property value result will not come only from specificity - it will be the result of the entire cascade process
  • "specified values" were mostly used incorrectly/confused with "declared values" - "specified values" result from the defaulting process after cascading, but the previous version didn't make this clear
  • The document mainly described the stages after the Defaulting process, even though the terminology and phases before Defaulting
    (which are Filtering, Cascading, and related terms) are necessary to make after-Defaulting values understandable. Omitting the before-Defaulting process essentially leads to misworded descriptions.
  • Initial value shouldn't be listed as a value processing stage according to the spec - it is the terminology used in the specified value resolution process

The change also includes some typo/wording updates, which will make the description more accurate or simpler.

Additional details

The changes ensure compliance with:

Related issues and pull requests

@sakupi01 sakupi01 requested a review from a team as a code owner July 27, 2025 10:58
@sakupi01 sakupi01 requested review from estelle and removed request for a team July 27, 2025 10:58
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs size/m [PR only] 51-500 LoC changed labels Jul 27, 2025
Copy link
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

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

Drive-by, just looking at Markdown correctness. Not interested in reviewing, although this looks like good work; thank you!


To determine which specified value is applied, the user agent gathers and processes all the styles from different sources, such as inline styles, and internal and external stylesheets.
To determine which [declared value](#declared-value) is applied, the user agent gathers and processes all the styles from different sources, such as inline styles, and internal and external stylesheets.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
To determine which [declared value](#declared-value) is applied, the user agent gathers and processes all the styles from different sources, such as inline styles, and internal and external stylesheets.
To determine which [declared value](#declared_value) is applied, the user agent gathers and processes all the styles from different sources, such as inline styles, and internal and external stylesheets.

Make sure all your anchor links are valid

@@ -10,50 +10,156 @@ For every element in a document tree, the browser assigns a value to every CSS p

## Property values

Every CSS property's value comes from the declaration with the greatest {{cssxref("specificity")}}. If two or more declarations with the same specificity provide different property values for the same element, the declaration value whose selector has the greatest algorithmic weight gets applied.
Every CSS property's value comes from the declaration that wins the {{cssxref("Cascade")}} algorithm. When multiple declarations provide different property values for the same element, the declaration that ranks highest in the [Cascade Sorting Order](/en-US/docs/Web/CSS/CSS_cascade/Cascade#cascading_order) gets applied.
Copy link
Member

Choose a reason for hiding this comment

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

CSS/Cascade is a redirect, plus {{cssxref("Cascade")}} would be rendered as code, so you should just use a markdown link instead. Also sentence case.

Suggested change
Every CSS property's value comes from the declaration that wins the {{cssxref("Cascade")}} algorithm. When multiple declarations provide different property values for the same element, the declaration that ranks highest in the [Cascade Sorting Order](/en-US/docs/Web/CSS/CSS_cascade/Cascade#cascading_order) gets applied.
Every CSS property's value comes from the declaration that wins the [cascade](/en-US/docs/Web/CSS/CSS_cascade/Cascade) algorithm. When multiple declarations provide different property values for the same element, the declaration that ranks highest in the [cascade sorting order](/en-US/docs/Web/CSS/CSS_cascade/Cascade#cascading_order) gets applied.

Same below.


```css
/* Example of inherited property */
color: /* inherits from parent's computed value */
Copy link
Member

Choose a reason for hiding this comment

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

?

@sakupi01
Copy link
Author

sakupi01 commented Jul 27, 2025


Each property value comes from a single property-value pair; is single value is applied from each property. Even if the value is a comma separated list of values, that list of values came from a single declaration.
Each property value comes from a single property name-value pair; a single value is applied from each property. Even if the value is a comma separated list of values, that list of values came from a single declaration.
Copy link
Author

Choose a reason for hiding this comment

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


To determine which specified value is applied, the user agent gathers and processes all the styles from different sources, such as inline styles, and internal and external stylesheets.
To determine which [declared value](#declared_value) is applied, the user agent gathers and processes all the styles from different sources, such as inline styles, and internal and external stylesheets.
Copy link
Author

@sakupi01 sakupi01 Jul 27, 2025

Choose a reason for hiding this comment

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

The term "specified value" was confusing in the entire context.
"specified value" comes after declaration value and cascaded value, but here it sounded like it comes before cascading.

https://www.w3.org/TR/css-cascade-4/#value-stages

@@ -10,50 +10,156 @@ For every element in a document tree, the browser assigns a value to every CSS p

## Property values

Every CSS property's value comes from the declaration with the greatest {{cssxref("specificity")}}. If two or more declarations with the same specificity provide different property values for the same element, the declaration value whose selector has the greatest algorithmic weight gets applied.
Every CSS property's value comes from the declaration that wins the [cascade](/en-US/docs/Web/CSS/CSS_cascade/Cascade) algorithm. When multiple declarations provide different property values for the same element, the declaration that ranks highest in the [cascade sorting order](/en-US/docs/Web/CSS/CSS_cascade/Cascade#cascading_order) gets applied.
Copy link
Author

@sakupi01 sakupi01 Jul 27, 2025

Choose a reason for hiding this comment

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

It could be read like property value comes because of only from the resolution of the specificity algorithm, but it's actually not.

The [cascade](/en-US/docs/Web/CSS/CSS_cascade/Cascade) determines which value should be applied when multiple conflicting styles target the same element. The cascade algorithm defines how user agents combine property values originating from different sources, scopes, and/or layers. When a selector matches an element, the property's [specified value](#specified_value) from the origin with the highest precedence gets applied, even if a selector from a lower precedence origin or layer has greater {{cssxref("specificity")}}.
After applying the [cascading](#cascading) rules and defaulting values step by step, the browser ensures the visual presentation matches the processed CSS.

## Processing overview
Copy link
Author

@sakupi01 sakupi01 Jul 27, 2025

Choose a reason for hiding this comment

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

In order not to use "specified value" incorrectly (or to use "declared value" and "cascaded value" correctly), and in order to follow Value Processing steps based on the spec, the pre-description of three processing steps, which are Filtering, Cascading, and Defaulting, is essentially needed.

Comment on lines +83 to 87
- [Declared value](#declared_value)
- [Cascaded value](#cascaded_value)
- [Specified value](#specified_value)
- [Computed value](#computed_value)
- [Used value](#used_value)
Copy link
Author

@sakupi01 sakupi01 Jul 27, 2025

Choose a reason for hiding this comment

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

The terminology "Initial value" is used IN the resolution phase of specified value, that is Defaulting phase - it's not the term to describe the part of value processing flow.

https://www.w3.org/TR/css-cascade-4/#value-stages
https://www.w3.org/TR/css-cascade-4/#defaulting

@sakupi01 sakupi01 changed the title renew css value processing document Refine CSS Value Processing document Jul 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:CSS Cascading Style Sheets docs size/m [PR only] 51-500 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants