Web Design Web Design Forum
Registration is free! Here you can view your subscribed threads, work with private messages and edit your profile and preferences Calendar Find other members Frequently Asked Questions Search
Home Web Design

Convenient web based access to our favorite web design Usenet groups

web design reviews

This is Interesting: Free Magazines for Graphics designers and webmasters  





  Last Thread  Next Thread
Author
Thread Post New Thread   

td selector question
 

Andrew Poulos




quote this post edit post

IP Loged report this post

Old Post  01-19-05 - 09: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


Post Follow-Up to this message ]
Re: td selector question
 

Steve Pugh




quote this post edit post

IP Loged report this post

Old Post  01-19-05 - 12:18 PM  
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/>


Post Follow-Up to this message ]
Re: td selector question
 

Christoph Paeper




quote this post edit post

IP Loged report this post

Old Post  01-19-05 - 12:18 PM  
*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


Post Follow-Up to this message ]
Re: td selector question
 

Christoph Paeper




quote this post edit post

IP Loged report this post

Old Post  01-26-05 - 09: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


Post Follow-Up to this message ]
Sponsored Links
 





All times are GMT. The time now is 10:09 AM. Post New Thread   
  Previous Last Thread   Next Thread next
Stylesheets archive | Show Printable Version | Email this Page | Subscribe to this Thread

Popular forums

Adobe Photoshop forum Macromedia Flash Web Site Design
Dreamweaver FrontPage forum
JavaScript Forum XML forum
Style Sheets VRML
Forum Jump:
Rate This Thread:

 

XML RSS Feed web design latest articles Syndicate our forum via XML or simple JavaScript

Web Design archive  Database administration help  


Top Home  -  Register  -  Control Panel   -  Memberlist  -  Calendar  -  Faq  -  Search Top