I’ve been dipping into SitePoint book concerning CSS.
The thing that struck me about the examples was the use of ID as a CSS selector.
Some bits of CSS design I’ve done, I’ve always found it easier and more versatile to use Class as the selector.
Maybe its a .Net thing as we don’t always have control of the ID of an element…
Is the best practice here to use CLASS or ID as the selector?
I guess they always use the id in examples because it’s less ambiguous. You know that they’re talking specifically about that one element and its styles.
In general, the rule of thumb is that you should ask yourself: ‘is there more than one element which requires the same style, now or at any time in the future?’, and the answer is even ‘maybe’, then make it a class.