A simple selector problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    A simple selector problem

    Hi there,

    I'm relatively new to CSS and having a difficult time with something that
    should be simple. I've searched this group for answers to this problem, but
    am afraid I haven't been able to find anything. It's probably just over my
    head.

    The problem is that I have a <li> which includes a nested <ul> with it's own
    <li>'s. I want to select the original <li>, but can't seem to do it without
    also selecting the nested <ul>'s <li>s. Here's the html/style


    Thanks so much for any advice,
    Elizabeth



  • Stephen Poley

    #2
    Re: A simple selector problem

    On Wed, 09 Nov 2005 04:17:51 GMT, <yosifhamod@ear thlink.net> wrote:
    [color=blue]
    >Hi there,
    >
    >I'm relatively new to CSS and having a difficult time with something that
    >should be simple. I've searched this group for answers to this problem, but
    >am afraid I haven't been able to find anything. It's probably just over my
    >head.
    >
    >The problem is that I have a <li> which includes a nested <ul> with it's own
    ><li>'s. I want to select the original <li>, but can't seem to do it without
    >also selecting the nested <ul>'s <li>s. Here's the html/style
    >http://www.hamneggs.net/visionact/horiz_brief.html[/color]


    You have "div#nav li.who a" which selects all <a> elements which are
    descendants of li.who. You want the child selector: div#nav li.who > a

    Actually I'd suggest using just: .who > a

    Sadly however still not supported (AFAIK) by any of the myriad versions
    of IE. So if you care about IE victims than you need to add an extra
    class to your top-level <a> elements.

    --
    Stephen Poley


    Comment

    • Spartanicus

      #3
      Re: A simple selector problem

      <yosifhamod@ear thlink.net> wrote:
      [color=blue]
      >The problem is that I have a <li> which includes a nested <ul> with it's own
      ><li>'s. I want to select the original <li>, but can't seem to do it without
      >also selecting the nested <ul>'s <li>s.[/color]

      You'd need the child selector ">" for that which is not supported by IE.
      To get around that you could specify a class for the <li>s you want to
      target, or, depending on what you want to do, you may be able to use
      multiple descendant selectors, for example like so:

      ul li{color:green}
      li li{color:black}

      --
      Spartanicus

      Comment

      • Guest's Avatar

        #4
        Re: A simple selector problem

        Thanks so much. I did end up specifying a class for the <li> I was
        targeting.

        Elizabeth

        "Spartanicu s" <invalid@invali d.invalid> wrote in message
        news:mfd3n1db3m vnd10v8dtjoh21o je87u8dib@news. spartanicus.utv internet.ie...[color=blue]
        > <yosifhamod@ear thlink.net> wrote:
        >[color=green]
        > >The problem is that I have a <li> which includes a nested <ul> with it's[/color][/color]
        own[color=blue][color=green]
        > ><li>'s. I want to select the original <li>, but can't seem to do it[/color][/color]
        without[color=blue][color=green]
        > >also selecting the nested <ul>'s <li>s.[/color]
        >
        > You'd need the child selector ">" for that which is not supported by IE.
        > To get around that you could specify a class for the <li>s you want to
        > target, or, depending on what you want to do, you may be able to use
        > multiple descendant selectors, for example like so:
        >
        > ul li{color:green}
        > li li{color:black}
        >
        > --
        > Spartanicus[/color]


        Comment

        Working...