Welcome to WebmasterWorld Guest from

Forum Moderators: not2easy

Message Too Old, No Replies

How to apply style to all TD in a particular Table

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

New User

10+ Year Member

joined:Nov 10, 2004
votes: 0

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

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

Senior Member from CA 

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

joined:Aug 31, 2003
votes: 4

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

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>

And the CSS:

table.widget td {
border-top:1px solid #000;
border-bottom:1px solid #000;
2:13 pm on Nov 10, 2004 (gmt 0)

New User

10+ Year Member

joined:Nov 10, 2004
votes: 0


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

Thanks for your response,
Marc Robson


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members