Comments on: Let’s use (X, X, X, X) for talking about specificity https://css-tricks.com/lets-use-x-x-x-x-for-talking-about-specificity/ Tips, Tricks, and Techniques on using Cascading Style Sheets. Thu, 06 May 2021 16:37:13 +0000 hourly 1 https://wordpress.org/?v=6.1.1 By: Nathan Pierce https://css-tricks.com/lets-use-x-x-x-x-for-talking-about-specificity/#comment-1771629 Thu, 06 May 2021 16:37:13 +0000 https://css-tricks.com/?p=339449#comment-1771629 Great article. I’ve always thought that writing the specificity without a separator was ambiguous and could cause trouble. Thanks for putting this out there.

I also agree that we can remove inline styles from the calculation–for brevity–as we do with the !important keyword, since both negate everything else. And most of the time they aren’t (read: shouldn’t) be used. Plus, (X, X, X) is simply more readable than (X, X, X, X, X).

BTW–ul#nav.top has a specificity of (0, 1, 1, 1), not “(0, 1, 0, 1).”

]]>
By: Juraj https://css-tricks.com/lets-use-x-x-x-x-for-talking-about-specificity/#comment-1771597 Wed, 05 May 2021 18:27:40 +0000 https://css-tricks.com/?p=339449#comment-1771597 In reply to Christopher Holland.

Agree. Similar to the version number.

]]>
By: mholzschlag https://css-tricks.com/lets-use-x-x-x-x-for-talking-about-specificity/#comment-1771554 Tue, 04 May 2021 20:34:37 +0000 https://css-tricks.com/?p=339449#comment-1771554 Cool walk down memory lane thanks for the CSS specificity fun! I do suggest swapping This is a very useful tool for generally weighing the specificity of a given selector. The model will as you point out fail if we calculate using a fixed 10 rather than the ‘broad’ base in CSS specificity algorithm. One factor that I believe has muddied the waters even more than the concept of a broad algorithm for folks is how the !important declaration factors in to weight calculations. This has caused over-reliance on that declaration to resolve specificity conflicts which, when resolved in the CSS with a more specific selector, the !important declaration can be used for the purpose which it was intended: To ensure my User Style Sheet rules actually do override the Author rules provided, usually because I have an #A11Y concern and am applying my personal styles out of need. Otherwise, the elegance of the Cascade ends up broken. Some of users still want to employ baked in clean CSS approaches of scale. Thank you for getting me enthusiastic about specificity again, for some reason a long lived enchantment born of my own DOH! Moments from the bad ol days

]]>
By: Christopher Holland https://css-tricks.com/lets-use-x-x-x-x-for-talking-about-specificity/#comment-1771552 Tue, 04 May 2021 17:41:57 +0000 https://css-tricks.com/?p=339449#comment-1771552 You could use a dot-notation and then the idea of a bigger number being more specific would hold true.
1.0.1 vs. 0.11.1

]]>
By: zakius https://css-tricks.com/lets-use-x-x-x-x-for-talking-about-specificity/#comment-1771551 Tue, 04 May 2021 16:08:36 +0000 https://css-tricks.com/?p=339449#comment-1771551 so like semver it doesn’t overflow to the more meaningful part, it absolutely makes sense

]]>