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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Just draw internal borders of table

Status
Not open for further replies.

miraclemaker

Programmer
Oct 16, 2002
127
GB
Can anyone tell me how to define a CSS class that will just draw the internal borders of a table ?

say I have a black page with a red table on it. I just want the borders between the cells of the table to be drawn, and not the border around the outside of the table (if that makes sense)

Also, I want that table to be able to contain more tables, without having the same stle applied to the internal tables.

Thanks for any help anyone can give me.
 
why don't you just give individual cells the border?
<body >
<style>
.boxedcell
{
border:1px solid red;
}
</style>


<table align=&quot;center&quot; width=&quot;50%&quot; cellspacing=&quot;5&quot; cellpadding=&quot;5&quot; >
<tr class=&quot;boxedcell&quot;>
<td bgcolor=&quot;#DDDDFF&quot;>cells
</td>
<td>&nbsp;with</td>
<td>&nbsp;out</td>
<td>&nbsp;border</td>
</tr>
<tr>
<td bgcolor = &quot;#FFFFFF&quot; class=&quot;boxedcell&quot;>
<p>
cells
&nbsp;</p>
</td>
<td class=&quot;boxedcell&quot;><p>with&nbsp;</p></td>
<td class=&quot;boxedcell&quot;><p>borders&nbsp;</p></td>
<td class=&quot;boxedcell&quot;><p>&nbsp;</p></td>

</tr>
</table>


</body>

grtfercho çB^]\..
&quot;Imagination is more important than Knowledge&quot; A. Einstein
 
Because that still gives a border around the outside of the table (the border of the cells on the edges of the table give the table itself a border)
 
then create a different class for the cells that hit the edges of the table


<body >
<style>
.boxedcell
{
border:1px solid red;
}
.boxedcellright
{
border-bottom : thin solid Black;
border-left : thin solid Black;
border-right : thin none Black;
border-top : thin solid Black;
}
.boxedcellleft
{
border-bottom : thin solid Black;
border-left : thin none Black;
border-right : thin solid Black;
border-top : thin solid Black;
}
.boxedcelltop
{
border-bottom : thin solid Black;
border-left : thin solid Black;
border-right : thin solid Black;
border-top : thin none Black;
}
.boxedcellbottom
{
border-bottom : thin none Black;
border-left : thin solid Black;
border-right : thin solid Black;
border-top : thin solid Black;
}

.boxedtopright
{
border-bottom : thin solid Black;
border-left : thin solid Black;
border-right : thin none Black;
border-top : thin none Black;
}
.boxedtopleft
{
border-bottom : thin solid Black;
border-left : thin none Black;
border-right : thin solid Black;
border-top : thin none Black;
}
.boxedbottomleft
{
border-bottom : thin none Black;
border-left : thin none Black;
border-right : thin solid Black;
border-top : thin solid Black;
}
.boxedbottomright
{
border-bottom : thin none Black;
border-left : thin solid Black;
border-right : thin none Black;
border-top : thin solid Black;
}
</style>


<table align=&quot;center&quot; width=&quot;50%&quot; cellspacing=&quot;5&quot; cellpadding=&quot;5&quot; >
<tr >
<td class=&quot;boxedtopleft&quot;>topleft</td>
<td class=&quot;boxedcelltop&quot;> top</td>
<td class=&quot;boxedcelltop&quot;> top</td>
<td class=&quot;boxedtopright&quot;> topright</td>
</tr>
<tr>
<td class=&quot;boxedcellleft&quot;> <p> left</p></td>
<td class=&quot;boxedcell&quot;><p>center</p></td>
<td class=&quot;boxedcell&quot;><p>center</p></td>
<td class=&quot;boxedcellright&quot;><p>right </p></td>
</tr>
<tr>
<td class=&quot;boxedcellleft&quot;> <p> left</p></td>
<td class=&quot;boxedcell&quot;><p>center</p></td>
<td class=&quot;boxedcell&quot;><p>center</p></td>
<td class=&quot;boxedcellright&quot;><p>right </p></td>
</tr>
<tr>
<td class=&quot;boxedbottomleft&quot;>bottomleft</td>
<td class=&quot;boxedcellbottom&quot;>bottom</td>
<td class=&quot;boxedcellbottom&quot;>bottom</td>
<td class=&quot;boxedbottomright&quot;>bottomright</td>
</tr>
</table>


</body>

grtfercho çB^]\..
&quot;Imagination is more important than Knowledge&quot; A. Einstein
 
Jeez! That's a fair old amount of code!
Thanks for the sample, but I think it's a bit much. I came up with this code:

TABLE.red_table TR TD
{
padding: 4px 4px 4px 4px;
border: 2px solid red;
}
TABLE.red_table
{
border-collapse: collapse;
border-style:hidden;
}

which works perfectly in Opera. But ie still displays the border around the outside of the table (it seems it ignores the style:hidden). So it's no good.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top