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

Giving a table internal cell borders only 1

Status
Not open for further replies.

mcowen

Programmer
Oct 21, 2001
134
GB
Hi, all.
Bit of a noob question probably - I'm not too hot on css.

I want a table with cell borders but no border on the outside of the table. I want the first row to have no top border, the first col to have no left border, the last col to have no right and the bottom to have no bottom border.
Tried all sorts but cant get rid of the table's border.

Thanks in advance.

Matt
 
Use CSS to do the cell borders. You want to create a class for the first row and for the first column of cells.


Code:
table {
	border-collapse:collapse;
}
td { 
	border-top:1px solid black;
	border-left: 1px solid black;
	padding:4px;
}

tr.firstRow td {
	border-top:none;
}

td.firstCol {
	border-left:none;
}

Then do your table like this.

Code:
<table>
<tr class="firstRow">
<td class="firstCol">Cell</td>
<td>Cell</td>
<td>Cell</td>
</tr>
<tr>
<td class="firstCol">Cell</td>
<td>Cell</td>
<td>Cell</td>
</tr>
<tr>
<td class="firstCol">Cell</td>
<td>Cell</td>
<td>Cell</td>
</tr>
</table>

It's a little messy I guess, but it achieves what you wanted.

Foamcow Heavy Industries - Web design and ranting
Toccoa Games - Day of Defeat gaming community
Target Marketing Communications - Advertising, Direct Marketing and Public Relations
"I'm making time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top