4 ms·
Points 2, 3 and 4 are irrelevant here. Do not use IDs in CSS. Use them in markup and JS and tests, sure, just not in CSS. Point 1: The speed difference between
by csswizardry 15y ago
Points 2, 3 and 4 are irrelevant here. Do not use IDs in CSS. Use them in markup and JS and tests, sure, just not in CSS.
Point 1: The speed difference between a class and an ID is so, so slight that it's almost non-existent. The specificity difference between a class and an ID is massive.
- brawley 15y agoblather all you want, but the consensus here is IDs, when properly used, enable speed and specificity. you don't get to tell us what's best practice.
- talmand 15y agoAh yes, the almighty consensus has spoken. Dare not disagree or we shall smite you.
- lazerwalker 15y agoIf a given ID element is uniquely styled (a very common use case), it seems backwards to me to explicitly give it a class so that you can select it by class instead of by the ID that already exists.