Previous Message
Next Message

RE: [css-d] difference between class and id selectors

Sent by Marek Prokop on 31 January 2002 07:07


Jonathon:

Id is unique identifier and can be used on a page only once, 
while class is..., well, class and can be reused many times on 
the same page. This division has a quite logical consequences. 
Is an element unique? Use id. Is it class having more members 
(either right now, or possibly in the future)? Use class.

Moreover, there is another point of view here. Style sheets 
should work properly (e.i. give the correct results), however 
they should be efficient and properly structured as well, what 
can be achieved mostly by inheritance. That's why I always try 
to have as few classes as possible, rather use ids for a couple 
of top level elements and style anything else using html 
selectors and inheritance.

Regards,

Marek Prokop

> -----Original Message-----
> From:	Jonathon Delacour [EMAIL-REMOVED]]
> Sent:	Thursday, January 31, 2002 8:12 AM
> To:	[EMAIL-REMOVED]
> Subject:	[css-d] difference between class and id selectors
>
snip
>
> I'm wondering if someone can succinctly explain (or point to 
an
> explanation
> of) the fundamental difference(s) between CLASS and ID
> selectors. In all
> the books and online resources I've looked at, the examples
> given seem to
> me to be applicable to either selector. As in <p class="first-
> para"> or <p
> id="first-para">.
>
> To put it another way, are there circumstances in which one
> would always
> use an ID selector and not a CLASS selector (or vice versa)?
Previous Message
Next Message

Possibly related: