W3C home > Mailing lists > Public > www-style@w3.org > September 2010

CSS selector - Select parent element (li) if child element (a) has an attribute of href="#"

From: Matthew Millar <mattmill30@hotmail.com>
Date: Sun, 12 Sep 2010 01:03:52 +0100
Message-ID: <SNT116-W505258C8BECC31D8B97D3CC4760@phx.gbl>
To: <www-style@w3.org>

Hi,

I'm trying to streamline my code and I've found a few areas where i'm defining classes etc, where I can probably get away with using CSS logic.

However, i'm stuck on how to give a parent element certain css styles if its child element has a particular attribute.

Example:

<ol>
   <li><a href="somewhere.html">Somewhere Else</a></li>
   <li><a href="#">Current Page</a></li>

</ol>

I want to apply a background-color to the li with a child anchor element who has the attribute href="#".

I noticed on CSS 3 selectors and undefined (Blank) :contains selector and i'm not sure if this is what i'm looking for.

http://www.w3.org/TR/css3-selectors/#content-selectors

Thanks in advance for any help,

Matthew Millar
 		 	   		  
Received on Sunday, 12 September 2010 00:04:25 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:31 GMT