> home
> how we work
> who we're working for
> about us
> publications
> buy apache essentials
> client login

play
static·red
edmonton and area web development

Current Projects

Edmonton Weather


>>Le blog.

speakeasy archives


how to select a CSS element by context

<< FAQ... | Main | woohoo! >>

Cascading Style Sheets, level 1: Contextual Selectors

Came across this working on a personal project. I was looking for a way to change the nature of anchors within a specific <div>, but I didn't want to set up a special class for them within the stylesheet, so I wouldn't have to edit the main source.

This entry in the W3C recommendation showed me exactly how to do that.


A,A.visited {
color: white; }
.light A,A.visited {
color:black; }

The above will render all anchor tags on the page in white, with the exception of anchor tags within a <div class="light"> -- these will render in black...

Very simple, when all is said and done. Works in IE & Mozilla (tested). Should work in Opera too.

Posted by Darren James Harkness on Thursday, February 28, 2002 11:15 PM
Trackbacks...


Comments:

Post a comment









Remember personal info?


Comments:


* under no circumstances will your email address be traded for a sack of quarters. No-sirree.