view raw
jeffkee jeffkee - 1 year ago 46
HTML Question

Cannot put margin on <td> tag with neither CSS nor cellspacing attribute

For whatever reason, I have been unable to get any table cells to have margin between them. I want the table cells to have a grey background colour (over a white page background) so it looks like tiles with white between them.

I tried in the HTML,

<table cellspacing="3">

Also in the CSS,

table td {

Nothing works. The cells are still stuck together, like one big grey blob. Am I missing something very very basic here?

Here's the actual code:

<table width="100%" cellspacing="3">
<th>Document Number</th>
<th>BP Reference No.</th>
<th>Posting Date</th>
<th>Posting Week</th>
<th>Customer/Vendor Code</th>
<th>Customer/Vendor Name</th>
<th>Item No.</th>
<th>Item/Service Description</th>
<th>Item Group</th>
<th>Warehouse Code</th>
<th>Remaining Open Quantity</th>
<th>Line No.</th>
<th>Sales Employee Name</th>
<th>Fill Rate</th>
<td>NYSTROM INC.</td>
<td>Nystrom, Mort. 1-1/8'', Schl C~K, US26D, ST cam, 5pin, KS #43758</td>
<td>Mort Cylinders</td>
<td>KRE Management 1</td>


If someone still has this problem, try this in your CSS stylesheet:

table {
        border-collapse: separate;
        border-spacing: 10px 5px;

The values for border-spacing are two length measurements. The horizontal value comes first and applies between columns. The second measurement is applied between rows.

If you provide one value, it will be used both horizontally and vertically. The default setting is 0, causing the borders to double up on the inside grid of the table.