A word of warning: though padding-right
might solve your particular (visual) problem, it is not the right way to add spacing between table cells. What padding-right
does for a cell is similar to what it does for most other elements: it adds space within the cell. If the cells do not have a border or background colour or something else that gives the game away, this can mimic the effect of setting the space between the cells, but not otherwise.
As someone noted, margin specifications are ignored for table cells:
CSS 2.1 Specification – Tables – Visual layout of table contents
Internal table elements generate
rectangular boxes with content and
borders. Cells have padding as well.
Internal table elements do not have
margins.
What's the "right" way then? If you are looking to replace the cellspacing
attribute of the table, then border-spacing
(with border-collapse
disabled) is a replacement. However, if per-cell "margins" are required, I am not sure how that can be correctly achieved using CSS. The only hack I can think of is to use padding
as above, avoid any styling of the cells (background colours, borders, etc.) and instead use container DIVs inside the cells to implement such styling.
I am not a CSS expert, so I could well be wrong in the above (which would be great to know! I too would like a table cell margin CSS solution).
Cheers!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…