Forum Moderators: open

Message Too Old, No Replies

multiple classes vs browsers

         

darcbar

4:04 pm on Sep 30, 2009 (gmt 0)

10+ Year Member



Hi just wondering which browsers support multiple classes and also if theres any major downfalls to using them ?

D_Blackwell

5:46 pm on Sep 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



All browsers support all the classes that you want. No downside. You should be using classes generously.

The same with the id, the most powerful selector (having a higher specificity than class), though each named id can be used only once per document (page).

One should take care declaring an id and be certain that it will never be needed more than once per document. Most common id usage are for page headers, sidebars, main navigation, and footers. Anything in the middle of the page is more likely to find a situation where you will want to use the id twice - and then you are stuck with needing to hack a class for that declaration before it can be used. id planning is important - as is all site structure.
........................

Example:

#one-time-div {declaration block}

but oops, now (six months later) I want to use this several times on one page.

Fix:
#one-time-div, .fix-the-oops {declaration block}

and you can now use the same declaration for id or class.

swa66

8:20 pm on Sep 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



IE6 actually doesn't support multiple classes on a single element as a selector as far as I remember. But IE6 is handicapped in many more manners.
IE7.js fixes the problem.
[code.google.com...]

You could do
.foo {font-size: 200%;}
.bar {color: green;}
.foo.bar {background-color: orange;}

And then <p class="foo bar">test</p>
would be rendered large, green on orange

darcbar

8:59 am on Oct 1, 2009 (gmt 0)

10+ Year Member



Ok thanks for the js