Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Sep 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    The difference between...

    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:

    Code:
    	ul#mainMenu, ul  {
    		padding:0;
    		margin:0;
    		list-style-type:none;
    	}
    	ul#mainMenu ul {
    		margin-top:3px;
    	}
    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?

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    Regular Coder
    Join Date
    Jul 2004
    Location
    France
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    then is ot the same than

    ul#mainMenu > ul {
    margin-top:3px;
    }

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #5
    Regular Coder
    Join Date
    Jul 2004
    Location
    France
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks Roy !

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •