homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

How to apply style to all TD in a particular Table

10+ Year Member

Msg#: 4962 posted 1:38 am on Nov 10, 2004 (gmt 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



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

Msg#: 4962 posted 1:52 am on Nov 10, 2004 (gmt 0)

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>

And the CSS:

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


10+ Year Member

Msg#: 4962 posted 2:13 pm on Nov 10, 2004 (gmt 0)


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

Thanks for your response,
Marc Robson

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved