HTML table needs spacing between columns, not rows
If you can use inline styling, you can set the left and right padding on each td
.. Or you use an extra td
between columns and set a number of non-breaking spaces as @rene kindly suggested.
http://jsfiddle.net/u5mN4/
http://jsfiddle.net/u5mN4/1/
Both are pretty ugly ;p css ftw
In most cases it could be better to pad the columns only on the right so just the spacing between the columns gets padded, and the first column is still aligned with the table.
CSS:
.padding-table-columns td
{
padding:0 5px 0 0; /* Only right padding*/
}
HTML:
<table className="padding-table-columns">
<tr>
<td>Cell one</td>
<!-- There will be a 5px space here-->
<td>Cell two</td>
<!-- There will be an invisible 5px space here-->
</tr>
</table>
<table cellpadding="pixels"cellspacing="pixels"></table>
<td align="position"valign="position"></td>
cellpadding
="length in pixels" ~ The cellpadding attribute, used in the <table>
tag, specifies how much blank space to display in between the content of each table cell and its respective border. The value is defined as a length in pixels. Hence, a cellpadding="10"
attribute-value pair will display 10 pixels of blank space on all four sides of the content of each cell in that table.
cellspacing
="length in pixels" ~ The cellspacing attribute, also used in the <table>
tag, defines how much blank space to display in between adjacent table cells and in between table cells and the table border. The value is defined as a length in pixels. Hence, a cellspacing="10"
attribute-value pair will horizontally and vertically separate all adjacent cells in the respective table by a length of 10 pixels. It will also offset all cells from the table's frame on all four sides by a length of 10 pixels.
The better approach uses Shredder's css rule: padding: 0 15px 0 15px only instead of inline css, define a css rule that applies to all tds. Do This by using a style tag in your page:
<style type="text/css">
td {
padding: 0 15px;
}
</style>
or give the table a class like "paddingBetweenCols" and in the site css use
.paddingBetweenCols td {
padding: 0 15px;
}
The site css approach defines a central rule that can be reused by all pages.
If your doing to use the site css approach, it would be best to define a class like above and apply the padding to the class...unless you want all td's on the entire site to have the same rule applied.
Fiddle for using style tag
Fiddle for using site css