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>


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.


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


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.


Thanks in advance for any help,

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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:49:47 UTC