CSS Question: is it possible to redefine a tag only within the context of a certain class?
January 5, 2004 10:42 AM   Subscribe

CSS Question: is it possible to redefine a tag only within the context of a certain class?

For instance, if I have a class called text1, could I specify that any [a] element which is contained in a [span] with the text1 class have certain properties?

I know I could define it for each a with an a.text1 selector, what I want is to not have to set a class for each a element, but rather just wrap them all in the span.
posted by signal to Computers & Internet (4 answers total)
 
Best answer: .text1 a {
foo: bar;
}

I think that's what you're looking for.
posted by jpoulos at 10:45 AM on January 5, 2004


Best answer: Yup. You can get more specific with things like direct descendant selectors (.text1 > a {where anything in here applies only to an a element immediately inside an element with class="text1"}, but support is spotty). If you want to be more specific in your given example you could use span.text1 a -- where only a elements inside a span with class="text1" would be affected.

The SelectOracle can help.
posted by yerfatma at 10:56 AM on January 5, 2004


Response by poster: Yep, that's it.
Thanks, rock much, both of you.
posted by signal at 11:04 AM on January 5, 2004


There's surprisingly good support for css selectors too. They work in IE4+, Mozilla, Konq 2.2+, and Opera 6+.

(haven't checked Netscape 4. I don't dare)
posted by holloway at 12:41 PM on January 5, 2004


« Older Shopkeeping   |   Tips for writing a graduate school Personal... Newer »
This thread is closed to new comments.