Welcome to WebmasterWorld Guest from 50.19.53.104

Forum Moderators: not2easy

Message Too Old, No Replies

How to apply style to all TD in a particular Table

     

marcrobson

1:38 am on Nov 10, 2004 (gmt 0)

10+ Year Member



I have a dynamically generated table which could be up to 6 columns by 100 rows. I would like these TD to have a top border and a bottom border (no side borders). On this page I have several other tables which do not use borders.

I know how to do this with CSS by assigning a class to each TD and defining that class with the desired border characteristics.

In some situations my agent is having a problem with the size of HTML and class="cellborder" times 600 cells equals my best opportunity to reduce the size of the dynamically generated HTML.

One option would be to skip the "cellborder" class and instead define TD to have these border characteristics. This is unacceptable because it would add a top and bottom border to ALL cells on the page and I have several other tables which need to have no border.

What I would like is for the Table to somehow identify that all of its cells are members of a particular class or have a particular style.

Is there any way that a TD can inherit its class from the Table?

Thanks in advance,
Marc Robson

PS - this might be a pretty basic question, I am still learning CSS

encyclo

1:52 am on Nov 10, 2004 (gmt 0)

WebmasterWorld Senior Member encyclo is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Welcome to WebmasterWorld [webmasterworld.com], marcrobson.

The easiest way to do this is to assign a class to the table, then add a style rule for all the

td
elements within that table:

<table cellpadding="0" cellspacing="0" [b]class="widget"[/b]>
<tr><td>your content</td></tr>
<tr><td>your content</td></tr>
<tr><td>your content</td></tr>
</table>

And the CSS:

table.widget td {
border-top:1px solid #000;
border-bottom:1px solid #000;
}

marcrobson

2:13 pm on Nov 10, 2004 (gmt 0)

10+ Year Member



PERFECT!

This is going to be so handy in lots of places!

Thanks for your response,
Marc Robson

 

Featured Threads

Hot Threads This Week

Hot Threads This Month