3 ms·
But that only works if you only need to increase "class-level" specificity. If you're trying to overwrite a style set with IDs, you're gonna need to either use
by mort96 5y ago
But that only works if you only need to increase "class-level" specificity. If you're trying to overwrite a style set with IDs, you're gonna need to either use IDs yourself or use !important. Sometimes you may not want to use IDs.
- csnover 5y agoRight—you can do the same thing with ID selectors, they just always have a higher specificity because they are in bucket A[0], whereas virtually all the other selectors are in bucket B. If you really have to select that element by ID for some reason, you can use an attribute selector instead—`[id=foo]`—and then it’s also in bucket B and can be controlled in the normal way. Basically, you should consider ID selectors (and element selectors) an antipattern and never use them. [0] https://www.w3.org/TR/selectors-4/#specificity-rules https://www.w3.org/TR/selectors-4/#specificity-rules