Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS border question

Status
Not open for further replies.

ThinkGeekness

Technical User
Jan 20, 2003
55
0
0
US
I have one last question and then I think that I am good to go. I have the css code:

.bodyline { background-color: #000000; border-top : 1px solid #616161; border-bottom : 1px solid Black; border-left : 1px solid Black; border-right : 1px solid Black; }

This code only does the outer border of the table. How would you code it so that it has the border for the inner part also (td's).

Thanks

 
If you apply the class to the TABLE it will only affect the outer border of that TABLE. To format the border of cells, you'd need to apply the class to each individual TD. You could either apply your bodyline class, or create another class if you want to have a different style border for the cells.

<table class=&quot;bodyline&quot;>
<tr>
<td class=&quot;someclass&quot;>Hello</td>
<td class=&quot;someclass&quot;>World</td>
</tr>
</table>

Miles

Those Micros~1 guys sure know what they doing!
 
Do it in your CSS like this:
[tt]
.bodyline,
.bodyline tr td,
.bodyline tr th {
background-color: #000000;
border-top : 1px solid #616161;
border-bottom : 1px solid Black;
border-left : 1px solid Black;
border-right : 1px solid Black;
}
[tt]
This will apply the borders to any element with a &quot;bodyline&quot; class, and to <td>s and <th>s within a <tr> within such an element.

-- Chris Hunt
Extra Connections Ltd

The real world's OK for a visit, but you wouldn't want to LIVE there!
 
Also keep in mind that applying a class to a tr will likely not work (depending on browser, most don't support it).
 
&quot;applying a class to a tr will likely not work&quot;

It will, but not all its properties will be inherited by the td's and th's enclosed in the <tr>. The cascade of properties within table elements is a pretty hit or miss affair, and subject to a lot of browser variation.

I've used class applied to a <tr> to change the background colour of a row of cells without problems (AFAIK), but it's probably safer to explicitly declare the cascade behaviour as I did in my previous posting.

-- Chris Hunt
Extra Connections Ltd

The real world's OK for a visit, but you wouldn't want to LIVE there!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top