Forum Moderators: not2easy
This distance between adjacent element borders is controlled by
margin and the distance between an element and its own border is controlled by padding Both should be very well supported.
So if you have html like this..
<div id="div1">
Div One
</div><div id="div2">
Div Two
</div>
#div1 {
border: 1px dashed red;
padding: 20px;
margin: 40px;
}#div2 {
border: 1px dashed green;
padding: 5px;
margin: 10px;
}
You should end up with two boxes one above the other. The content of the top box will keep at least 20 pixels away from its edge and the content of the bottom box will stay 5 pixels from the edge.
The two boxes will be 40 pixels apart (note 40, not 50, because margins collapse together)
If don't want a uniform margin then you can specify it as
margin: 1px 2px 3px 4px;, which specifies top,right,bottom,left margins in that order.
Alternatively, if you have to do it with CSS then bear in mind that you can still specify internal padding of cells.
table td {
padding: 5px;
}
which will look pretty much the same as cellspacing if you are not displaying cell borders.
If you need to display a border for your cell content then you could fake it by doing something cheesy like this..
table td {
padding: 5px;
border: none;
}
table td div {
padding: 1px;
border: 1px solid black;
}
<table>
<tr>
<td><div>Cell 1</div></td>
<td><div>Cell 2</div></td>
<tr>
<tr>
<td><div>Cell 3</div></td>
<td><div>Cell 4</div></td>
<tr>
</table>
Which is pretty horrible, but it works. ;)