Results 1 to 3 of 3

Thread: css ">" what means rather

  1. #1
    Join Date
    Jan 2012
    Posts
    74
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    #main > ul > li { list-style:none; float:left; }

    ">" what means rather

    #main ul a {

    ???

    Code:
    #main div {
      padding:10px 10px 8px 10px;
      *padding-top:3px;
      *margin-top:-15px;
      clear:left;
      background:snow;
      height: 300px ;
    }
    also what "*" mean?
    Last edited by jscheuer1; 02-17-2012 at 06:34 PM.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It's a child selector. Instead of the ul being anywhere within #main, it must be a direct descendant of #main like:

    HTML Code:
    <div id="main">
    <ul></ul>
    </div>
    Not a secondary or lower descendant like:

    HTML Code:
    <div id="main">
    <div><ul></div>
    </div>
    Often this is used to avoid styling nested elements of the same type. Like ul's within the ul or li's within the li.

    The asterisk * is technically invalid so will negate (remove) the rule that follows it on the same line. It's bad form and should be done like so:

    Code:
    #main div {
      padding:10px 10px 8px 10px;
      /* padding-top:3px; */
      /* margin-top:-15px; */
      clear:left;
      background:snow;
      height: 300px ;
    }
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    John is correct that the * makes those rules "invalid" (so browsers ignore them), but there's another purpose behind doing it.

    IE 7 and less do not ignore rules with a * in them.
    This IE bug led to the "star hack" which can be used to make CSS rules that apply only to IE6/7.

    It's still not a good thing, however, and I recommend against using it. If you need to target IE6/7, you should use conditional comments or javascript (for feature detection).
    Last edited by traq; 02-20-2012 at 12:07 AM. Reason: rephrasing

Bookmarks

Posting Permissions

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