Skip to content

Clarify specificity as value - #44009

Merged
estelle merged 3 commits into
mdn:mainfrom
caio-bittencourt:fix/specificity-clarify-44000
May 12, 2026
Merged

Clarify specificity as value#44009
estelle merged 3 commits into
mdn:mainfrom
caio-bittencourt:fix/specificity-clarify-44000

Conversation

@caio-bittencourt

Copy link
Copy Markdown
Contributor

Description

Clarifies that specificity is a value (weight) computed by the specificity algorithm and used in the cascade, removing wording that implied specificity itself is an algorithm.

Motivation

The current phrasing is conceptually inconsistent and can confuse readers. This makes the explanation more precise and aligns with how the cascade uses specificity values.

Additional details

N/A

Related issues and pull requests

Fixes #44000

@caio-bittencourt
caio-bittencourt requested a review from a team as a code owner May 5, 2026 01:15
@caio-bittencourt
caio-bittencourt requested review from hamishwillee and removed request for a team May 5, 2026 01:15
@github-actions github-actions Bot added Content:CSS Cascading Style Sheets docs size/s [PR only] 6-50 LoC changed labels May 5, 2026

@hamishwillee hamishwillee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This sounds correct/better to me, but I'm not a CSS expert. @estelle Can you please look at this?

@hamishwillee
hamishwillee requested a review from estelle May 5, 2026 01:57
@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

Preview URLs (1 page)

Flaws (5)

Found an unexpected or unresolvable flaw? Please report it here.

URL: /en-US/docs/Web/CSS/Guides/Cascade/Specificity
Title: Specificity
Flaw count: 5

  • macros:
    • Macro cssxref produces link /en-US/docs/Web/CSS/Universal_selectors which is a redirect
    • Macro cssxref produces link /en-US/docs/Web/CSS/Next-sibling_combinator which is a redirect
    • Macro cssxref produces link /en-US/docs/Web/CSS/Child_combinator which is a redirect
    • Macro cssxref produces link /en-US/docs/Web/CSS/Subsequent-sibling_combinator which is a redirect
    • Macro cssxref produces link /en-US/docs/Web/CSS/Column_combinator which is a redirect

(comment last updated: 2026-05-12 09:34:58)

@estelle estelle left a comment

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.

Thank you for the PR. This is a topic where we have to be super pedantic in translating something that is pretty complex. While the spec doesn't use the term "weight", to make people understand the topic, it makes sense to use that word. Similarly, the spec doesn't use columns or dashes, but, again, to make people understand, it makes sense to use those terms, but we can't say that that is how user agents do it. We also have to always be clear that specificity is only relevant within the a single origin layer (and scope?). I think my feed back does that.

Comment thread files/en-us/web/css/guides/cascade/specificity/index.md Outdated
Comment thread files/en-us/web/css/guides/cascade/specificity/index.md Outdated
Comment thread files/en-us/web/css/guides/cascade/specificity/index.md Outdated
Comment thread files/en-us/web/css/guides/cascade/specificity/index.md Outdated
Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>

@estelle estelle left a comment

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.

Thank you, and congratulations on your first merged MDN content PR.

Just a pointer for future PRs:
When you want the reviewer to re-review a PR, click on the icon by their name in the reviewer section. This alerts the person that a PR is ready to be re-reviewed. The icon is the two arrows next to a bubble comments made icon (as shown in the screen shot) or a red page with a +/- changes requested icon (the green checkmark means "approved").

Screenshot of reviewer section of PR with the rereview icons

Clicking on the two arrows sends the reviewer an alerts, and changes the comment bubble or red +/- icon to a brown dot. This is another indicator that you are done editing and ready to have the PR re-visited.

Thanks. Welcome to the team!

---

**Specificity** is the algorithm used by browsers to determine the [CSS declaration](/en-US/docs/Learn_web_development/Core/Styling_basics/What_is_CSS#css_syntax_basics) that is the most relevant to an element, which in turn, determines the property value to apply to the element. The specificity algorithm calculates the weight of a [CSS selector](/en-US/docs/Web/CSS/Reference#selectors) to determine which rule from competing CSS declarations gets applied to an element.
**Specificity** is the weight that browsers use in the cascade algorithm to determine the [CSS declaration](/en-US/docs/Learn_web_development/Core/Styling_basics/What_is_CSS#css_syntax_basics) that is the most relevant to an element, which in turn, determines the property value to apply to the element. The specificity algorithm calculates this weight from a [CSS selector](/en-US/docs/Web/CSS/Reference#selectors), and compares the resulting values to decide which rule, from competing CSS declarations within the same origin and layer, gets applied to an element.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[mdn-linter] reported by reviewdog 🐶

Suggested change
**Specificity** is the weight that browsers use in the cascade algorithm to determine the [CSS declaration](/en-US/docs/Learn_web_development/Core/Styling_basics/What_is_CSS#css_syntax_basics) that is the most relevant to an element, which in turn, determines the property value to apply to the element. The specificity algorithm calculates this weight from a [CSS selector](/en-US/docs/Web/CSS/Reference#selectors), and compares the resulting values to decide which rule, from competing CSS declarations within the same origin and layer, gets applied to an element.
**Specificity** is the weight that browsers use in the cascade algorithm to determine the [CSS declaration](/en-US/docs/Learn_web_development/Core/Styling_basics/What_is_CSS#css_syntax_basics) that is the most relevant to an element, which in turn, determines the property value to apply to the element. The specificity algorithm calculates this weight from a [CSS selector](/en-US/docs/Web/CSS/Reference#selectors), and compares the resulting values to decide which rule, from competing CSS declarations within the same origin and layer, gets applied to an element.

Specificity is the weight that is applied to a given CSS declaration. The specificity algorithm calculates that weight based on the number of [selectors of each weight category](#selector_weight_categories) in the selector matching the element (or pseudo-element). If there are two or more declarations providing different property values for the same element, the declaration value in the style block having the matching selector with the greatest weight gets applied.

The specificity algorithm is basically a three-column value of three categories or weights - ID, CLASS, and TYPE - corresponding to the three types of selectors. The value represents the count of selector components in each weight category and is written as _ID - CLASS - TYPE_. The three columns are created by counting the number of selector components for each selector weight category in the selectors that match the element.
The specificity value is basically a three-column value of three categories or weights - ID, CLASS, and TYPE - corresponding to the three types of selectors. The value represents the count of selector components in each weight category and is written as _ID - CLASS - TYPE_. The three columns are created by counting the number of selector components for each selector weight category in the selectors that match the element.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[mdn-linter] reported by reviewdog 🐶

Suggested change
The specificity value is basically a three-column value of three categories or weights - ID, CLASS, and TYPE - corresponding to the three types of selectors. The value represents the count of selector components in each weight category and is written as _ID - CLASS - TYPE_. The three columns are created by counting the number of selector components for each selector weight category in the selectors that match the element.
The specificity value is basically a three-column value of three categories or weights - ID, CLASS, and TYPE - corresponding to the three types of selectors. The value represents the count of selector components in each weight category and is written as _ID - CLASS - TYPE_. The three columns are created by counting the number of selector components for each selector weight category in the selectors that match the element.

@estelle
estelle merged commit 2cae555 into mdn:main May 12, 2026
8 of 9 checks passed
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/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Specificity is not an algorithm

4 participants