By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,766 Members | 1,265 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,766 IT Pros & Developers. It's quick & easy.

contextual selectors

P: n/a

Having fun with using contextual selectors with tables and links

In this very simplified version of what I am doing, I want to apply a
specific style to all <td> tags, and the <a> tag in a single table,
without having to specify a class for each one.

<div class='one'>
<table>
<tr>
<td>some text</td>
</tr>
<tr>
<td><a href='foo'>some link</a></td>
</tr>

</table>
</div>

My attempt at doing this was

div.one td { properties : values;}
div.one a { properties : values;}

my understanding of how this works is that any <td> tag thats a child of
a <div> tag with a class of one, gets the style applied only.

the issue is that while this works, its being overridden by the next
declarations

div.two td { properties : values;}
div.two a { properties : values;}

I must be missing something here?

Thanks for the help
--

www.ozetechnology.com
Powered by: Penguins and Apples
Proud to be 100% Microsoft Free
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
*TheMartian* <me@privacy.net>:

specific style to all <td> tags, and the <a> tag in a single table,

<div class='one'><table>
<tr><td>some text</td></tr>
<tr><td><a href='foo'>some link</a></td></tr>
</table></div>

div.one td { properties : values;}

my understanding of how this works is that any <td> tag thats a child of
a <div> tag with a class of one, gets the style applied only.
That's correct.
the issue is that while this works, its being overridden by the next
declarations

div.two td { properties : values;}


Is there a 'div' with class "two" anywhere in the code that you didn't
quote?

--
The Hitchhiker's Guide to the Galaxy:
"In the beginning the Universe was created.
This has made a lot of people very angry
and been widely regarded as a bad move."
Jul 20 '05 #2

P: n/a
Christoph Paeper wrote:
*TheMartian* <me@privacy.net>:
specific style to all <td> tags, and the <a> tag in a single table,

<div class='one'><table>
<tr><td>some text</td></tr>
<tr><td><a href='foo'>some link</a></td></tr>
</table></div>

div.one td { properties : values;}

my understanding of how this works is that any <td> tag thats a child of
a <div> tag with a class of one, gets the style applied only.

That's correct.

the issue is that while this works, its being overridden by the next
declarations

div.two td { properties : values;}

Is there a 'div' with class "two" anywhere in the code that you didn't
quote?


figured it out, was a nested DIV issue

thanks for the help

--

www.ozetechnology.com
Powered by: Penguins and Apples
Proud to be 100% Microsoft Free

Jul 20 '05 #3

P: n/a
TheMartian <me@privacy.net> wrote in news:bqq4p6$256s8c$1@ID-
216756.news.uni-berlin.de:
div.one td { properties : values;}
div.one a { properties : values;}

my understanding of how this works is that any <td> tag thats a child of
a <div> tag with a class of one, gets the style applied only.


Any descendant, not just a child: the CSS syntax for specifying only a
child, rather than a grandchild, etc. would be "div.one>td" though that
could never apply to properly-written HTML since the only thing that a <td>
can be a child of is a <tr>. Note that MSIE doesn't understand the child-
only syntax.

IOW, if you have a selector where two element names are separated by
spaces, it will apply even when there are many elements nested in between
the two named ones.

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.