View Full Version : The difference between...

09-20-2004, 07:55 PM
I've been trying to study up on hovering css list navigations and I've been looking through several examples. On one of them I see:

ul#mainMenu, ul {
ul#mainMenu ul {

What is the difference between the two styles? One has a , and the other doesn't, but they look the same to me. Couldn't the margin-top be added to the first one?

Roy Sinclair
09-20-2004, 08:38 PM
That comma makes all the difference in the world, the first one with the comma means the following CSS rules applies to all UL tags (the more specific selector prior to the comma is effectively ignored) while the second one without the comma means that it only applies to UL tags that are embedded within a UL tag that has an ID value of mainMenu.

See: http://www.w3.org/TR/CSS2/selector.html

09-20-2004, 09:11 PM
then is ot the same than

ul#mainMenu > ul {

Roy Sinclair
09-20-2004, 09:37 PM
Replacing the space with a greater than takes it from applying to ANY UL tag which is a descendant of the UL tag with an ID of mainMenu to applying to only any UL tag which is a direct child. Effectively that's a useless rule because you've got to have a LI under a UL so you'll not be able to have another UL as a child of a UL.

09-21-2004, 06:21 AM
thanks Roy !

Roy Sinclair
09-21-2004, 03:38 PM
I forgot to mention that a certain browser used by the vast majority of the users on the web right now doesn't honor the greater than selector anyway so there's another reason not to count on it's being usable right now.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum