Send to a Friend

makemo's avatar

Why not always use .Classes in CSS and skip #IDs alltogether?

Asked by makemo (531points) April 20th, 2008

If ID and Class means the same thing, with the exception that IDs can only target one element, whereas Classes can be used in multiple instances throughout the code:

Why not just use Classes all the time?

Of course, the one thing to pay attention to, would be to keep track on the elements having the same Class, for obvious reasons, but isn’t the extra effort keeping that in mind kind of worth it, rather than using IDs and then realize tha you want to use that same declaration on multiple elements, ultimately being forced to change the attribute from ID to Class anyway…

I’m a bit confused about this, and would like to hear some opinions, or, if somebody could point me to some place where this is being discussed in detail. I’d be curious to know, are there different ‘schools’ in this regard? I tend to believe that I’m better off using Classes as attributes for all my declarations (except for the standard elements, of course).

Thanks,
-Makemo

Using Fluther

or

Using Email

Separate multiple emails with commas.
We’ll only use these emails for this message.