This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Stylesheets > November 2005 > A simple selector problem





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author A simple selector problem

2005-11-09, 7:00 pm

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

Thanks so much for any advice,
Elizabeth



Stephen Poley

2005-11-09, 7:00 pm

On Wed, 09 Nov 2005 04:17:51 GMT, <yosifhamod@earthlink.net> wrote:

>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



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

http://www.xs4all.nl/~sbpoley/webmatters/
Spartanicus

2005-11-09, 7:00 pm

<yosifhamod@earthlink.net> wrote:

>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.


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

2005-11-10, 7:00 pm

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

Elizabeth

"Spartanicus" <invalid@invalid.invalid> wrote in message
news:mfd3n1db3mvnd10v8dtjoh21oje87u8dib@news.spartanicus.utvinternet.ie...
> <yosifhamod@earthlink.net> wrote:
>
own[color=darkred]
without[color=darkred]
>
> 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



Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews