Tags:



CSS Question: is it possible to redefine a tag only within the context of a certain class?
January 5, 2004 10:42 AM   RSS feed for this thread 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 comments total)
.text1 a {
foo: bar;
}

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


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


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 Has anyone had experience open...   |   I'd like to hear some tips inv... Newer »
This thread is closed to new comments.


Related Questions
I need to improve my CSS July 11, 2008
Lining up columns in CSS September 18, 2007
What web books do you recommend? June 25, 2007
Safari, You've Let Me Down April 19, 2007
Stuck in table/form hell! May 29, 2006