PDA

View Full Version : Spaces in Class Name (HTML and CSS)?


guitarandbeyond
06-26-2008, 08:01 AM
This

If I wanted to use this in CSS to change the td background color to b85823 only using the class name for the div and then the td, how would I label it?

Would it be:

.clearfix profileWidth tr td{background-color:b85823;}

abra?.us
06-26-2008, 08:59 AM
no

it would look like this

div.clearfix.profileWidth tr td {background-color:b85823;}

that isnt "a space in a class name" - it's "two classes" being applied to that div

Reveal my Identity?
06-26-2008, 10:01 AM
very close

The div, has two classes
clearfix
profileWidth
not one class with a space in it.


In this case, I would use the class profileWidth to address it, only because I know that it is using class clearfix on multiple divs, and I know that is the only div in class profileWidth

i.e. see this page for a diagram:
http://www.myspace.com/drhoovey

Basically you could do this

div.profileWidth table tr td {background-color:b85823 !important}

Because you are overriding inline style, that has been applied to that td, you do need to use !important.

The div in front of the .profileWidth can be left out.
the Table and Tr can be left out.

i.e. if I did this:

.profileWidth td {background-color:b85823 !important}

This tells me that for any td, that has some parent which is in class profileWidth, color the background b85823 UNLESS another command takes precedence.

Look at the page I pointed you to.
Notice how many td's actually qualify?
Even those that are deeper in the structure.