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!

What's CSS equivalent of cellspacing=0 cellpadding=0? 1

Status
Not open for further replies.

AndyGroom

Programmer
May 23, 2001
972
GB
Hi,

I've got a webpage with 20 or so tables, all with the same style and I want to use a stylesheet to optimise the code. My requirement is seemingly simple:

<table cellspacing=0 cellpadding=0 border=0>

However I can't find the CSS equivalent. The closest I've got so far is:

TABLE { border-width: 0 0 0 0; border-collapse: collapse;}

but that still gives me a 1px edge around the tables plus a weird right-hand edge down every cell that I can't account for - I only know that if I use my <table ... > formatting they disappear.

Please! What's the equivalent to my <table ... > properties in style-sheet syntax?


- Andy
_______________________________
&quot;On a clear disk you can seek forever&quot;
 
AFAIK, there is no CSS for cellspacing... you will have to hardcode cellspacing=&quot;0&quot; in the html code. I ran into this same problem last week.

When in doubt, deny all terms and defnitions.
 
Thanks. Is the rest of my style comparable to cellpadding=0 and border=0?


- Andy
_______________________________
&quot;On a clear disk you can seek forever&quot;
 
Try this:
Code:
table {border-spacing: 0px;}
td {padding: 0px;}

Kevin
A+, Network+, MCP
 
Code:
table {
     margin: 0px;
     padding: 0px;
     border-spacing: 0;
   }
 
Thanks all,

After a bit of experimentation I found that the only exact equivalent to what I asked for is:

TABLE { margin: 0px; border-spacing: 0; }
TD { padding: 0px;}

Without the TD tag I get a 1px border around each cell, so thanks to philote for that tip.


- Andy
_______________________________
&quot;On a clear disk you can seek forever&quot;
 
I was looking for the same because I cannot set properties on elements except the class (className in script).

IE6 seems to put some cellspacing in a table where it is not defigned, this is gone after setting
border-collapse: collapse ! importaint;
for a style called CellSpacingOff:

Code:
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css" href="content.css">
<TITLE></TITLE>
</HEAD>
<BODY bgcolor=#000000>
<table class="TableHeadColorOrangeHead CellSpacingOff BorderOn" style="width:100%">
	<tbody>
		<tr>
			<th>
				head
			</th>
			<th>
				head
			</th>
		</tr>
		<tr>
			<td>
				row
			</td>
			<td>
				row
			</td>

		</tr>
	</tbody>
</table>
</BODY>
</HTML>

Code:
.CellSpacingOff
{
	border-collapse: collapse ! importaint;
}
TABLE.TableHeadColorOrangeHead, TBODY.TableHeadColorOrangeHead
{}
.TableHeadColorOrangeHead TH
{
	BACKGROUND-COLOR: #CC6600;
}

.BorderOn
{
    BORDER-RIGHT: silver 1px solid ! importaint;
    BORDER-TOP: silver 1px solid ! importaint;
    BORDER-LEFT: silver 1px solid ! importaint;
    BORDER-BOTTOM: silver 1px solid ! importaint;
}



Greetings, Harm Meijer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top