[UPHPU] More CSS frustration
cole at colejoplin.com
cole at colejoplin.com
Wed Jan 17 14:23:35 MST 2007
Hi again,
First I want to say that I NEVER, EVER use inline CSS for any
production page. That would break the spirit of using CSS. I did it in
this example only, so you could easily copy and paste for
demonstrating the theory. So sorry if that was mistaken as an
indicator of real code I'd use.
Quoting Scott Hill <llihttocs at gmail.com>:
> I know I said one question but I can't resist. Just one more question.
> What are the guidelines for using the id or class attributes? When should
> you use one instead of the other? In other words, why not use all ids or
> all classes? What are the pros and cons of each? (Sorry, I got carried
> away. That's more than one question)
I've not seen an established guideline. Has anyone else? Myself, as a
long-time programmer, I'm conditioned for reusing functions and
objects, and leveraging inheritance. CSS classes imply reuse multiple
times on a page, while ids are unique to a page. By default, I use
classes, enabling reuse, and when I absolutely need uniqueness, I use
ids.
For example, I created a 3-tier menu once, that expanded and
collapsed, using javascript and nested <ul>s, where I had both general
classes and specific ids. I needed uniqueness for changing the visible
properties of the divs. I use inheritance to leverage properties in
parent divs to control child divs.
I hope that answers your questions okay.
-- Cole
More information about the UPHPU
mailing list