This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > Stylesheets > January 2005 > td selector question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
td selector question
|
|
| Andrew Poulos 2005-01-19, 4:22 am |
| If I have some HTML that looks like this:
<div class="option">
<table>
<tbody>
<tr>
<td>blah</td>
<td>blah</td>
</tr>
</tbody>
</table>
</div>
How can I create a selector that refers to the first TD and another
selector that refers to the second TD? I'd rather not add a class or id
attribute to the TDs. I've been experimenting with child, descendant etc
selectors but I can't get it working right.
Andrew Poulos
| |
| Steve Pugh 2005-01-19, 7:18 am |
| Andrew Poulos <ap_prog@hotmail.com> wrote:
>If I have some HTML that looks like this:
>
><div class="option">
> <table>
> <tbody>
> <tr>
> <td>blah</td>
> <td>blah</td>
> </tr>
> </tbody>
> </table>
></div>
>
>
>How can I create a selector that refers to the first TD and another
>selector that refers to the second TD? I'd rather not add a class or id
>attribute to the TDs. I've been experimenting with child, descendant etc
>selectors but I can't get it working right.
Does it need to work in IE?
If it does then you need to resort to classes, if it doesn't then
there are a number of possibilities, including :first-child to select
the first one and :last-child to select the last one; td + td to
select the second (and subsequent) cells; CSS3 offers nth-child()
which lets you styles any column you like with ease.
Actually IE can count cells so styling via the DOM is possible with
some JavaScript. By doing this the IE7 package of scripts
http://dean.edwards.name/IE7/ offers support for some of the CSS
selectors mentioned above.
Steve
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor
Steve Pugh <steve@pugh.net> <http://steve.pugh.net/>
| |
| Christoph Paeper 2005-01-19, 7:18 am |
| *Steve Pugh* <steve@pugh.net>:
> Andrew Poulos <ap_prog@hotmail.com> wrote:
>
>
> If it does then you need to resort to classes,
Some cases can be solved with added 'col's and IE's non-standard support
for them, though. Whether that was an option here, can't be told from that
code fragment.
> :first-child to select the first one and :last-child to select the last
> one; td + td to select the second (and subsequent) cells; CSS3 offers
> nth-child()
Just to be clear, ':last-child' is also from CSS_3 Selectors and thus is
not supported by, for instance, Opera_7, but by Gecko. The rest is CSS_2,
but not CSS_1, where MS only claims IE supporting the latter.
--
"What this country needs is more free speech worth listening to."
Hansell B. Duckett
| |
| Christoph Paeper 2005-01-26, 4:28 am |
| *Steve Pugh* <steve@pugh.net>:
> Andrew Poulos <ap_prog@hotmail.com> wrote:
>
>
> If it does then you need to resort to classes,
Some cases can be solved with added 'col's and IE's non-standard support
for them, though. Whether that was an option here, can't be told from that
code fragment.
> :first-child to select the first one and :last-child to select the last
> one; td + td to select the second (and subsequent) cells; CSS3 offers
> nth-child()
Just to be clear, ':last-child' is also from CSS_3 Selectors and thus is
not supported by, for instance, Opera_7, but by Gecko. The rest is CSS_2,
but not CSS_1, where MS only claims IE supporting the latter.
--
"What this country needs is more free speech worth listening to."
Hansell B. Duckett
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|