CSS horizontal table cell spacing: how?
How about giving each table cell a transparent border? I am pretty sure this will do it for you...
table td { border:solid 5x transparent;}
And you can only apply it horizontally like so...
table td { border-left:solid 10px transparent;}table td:first-child { border-left:0;}
Here's a complete working demo of what I believe you are trying to accomplish...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html> <head> <title>Layout</title> <style type="text/css"> table { border: 1px solid black; } table td { background: yellow; border-left:solid 10px transparent; } table td:first-child { border-left:0; } </style> </head> <body> <table> <tr> <td>1</td> <td>2</td> <td>3</td> </tr> <tr> <td>4</td> <td>5</td> <td>6</td> </tr> <tr> <td>7</td> <td>8</td> <td>9</td> </tr> </table> </body></html>
I do not believe IE6 supports the CSS :first-child, so here is a workaround for that...
<!–-[if IE 6]><style type="text/css"> table td { border-left: expression(this.previousSibling == null ? '0' : 'solid 5px transparent'); }</style><![endif]-->
It is may be what are you loking for:
You can use two values: the first is the horizontal cellspacing, the second the vertical one.
<table style="border-spacing: 40px 10px;">
try using col
s
example
<table> <col style="padding-right:20px;" /> <col style="padding-right:30px;" /> <col /> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> </tr></table>
cols also support classes :)
hope this helps
Darko
EDIT: To clarify a col
is an element declared at the top of the table to influence entire columns. The first col element will influence the first column, the second col = second column and so on. They can be grouped in colgroups if you wish to assign the same style to more than one column.
EDIT2: After some more research it turns out that the only reliable styles you can set on a col
element are:
- border
- background
- width
- visibility
No margin or padding. Bugger! Would setting the width of the columns explicitly solve your problem?