(no title)
SkeuomorphicBee | 1 year ago
> /* Do */
> [id="main"] { max-width: 80ch; }
> /* Don't */
> #main { Max-width: 80ch; }
I strongly disagree with this kind of guideline. The id attribute has very good uses, and in those cases the hash syntax should be the preferred way.
The use of id in an attribute selector is such a bad choice that makes me question the whole document.
emmacharp|1 year ago
As for the #selector, in what cases do you need that much specificity? Not a rhetorical question!
mock-possum|1 year ago
If you use an attribute selector, the engine must search through every single node in the DOM in order to return matches - an incredibly costly operation by comparison.
(Disclaimer, there may well be optimizations I’m not aware of at this point, but I’m pretty sure that’s why ids are generally preferred as a rule of thumb)