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

Issue with discussion of concatenation for specificity #34

Open
dtarvin opened this issue Nov 3, 2023 · 0 comments
Open

Issue with discussion of concatenation for specificity #34

dtarvin opened this issue Nov 3, 2023 · 0 comments

Comments

@dtarvin
Copy link

dtarvin commented Nov 3, 2023

Your discussion of concatenating for specificity has a problem with it - if c or d are both at 10 or above. What I mean is, if you have 10 or more classes or tag names, pushing the numbers together without any separating dashes or commas gives you an incorrect specificity.

Suppose 1 id, 10 classes and 2 tags - with concatenation, that gives you 1102, which is incorrect. If you have another element that is just 2 ids, no classes and no tags, the concatenated number would be 200, which beats the concatenation of 1102.

You also can't add the numbers together, because 10 classes do not have the same specificity as 1 id (Here's a CodePen where I put 100 classes and 1 id on an element: https://codepen.io/dtarvin/pen/gOqPKaM).

You can only show the true ranking of specificity by separating the numbers with dashes or something like this: 1-10-2, 2-0-0. The highest number in the first column wins. If they're the same the highest column in the second number wins. If they're the same the highest number in the third column wins. If they're the same the style that is lowest in the stylesheet wins.

I would be happy to submit a pull request on this if you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant