cellspacing : space between cellsAs the word "cellspacing" suggests, it denotes the spacing between cells; it is something easy to remember. "cellpadding" keyword can be considered in relation to the "padding" attribute in HTML/CSS; padding is used to denote the space between the content and border of box type elements.
cellpadding : space between the cell border and it's content
Look at the diagram to clarify this further.
Following is a simple code example to demonstrate the difference.
<table cellspacing="15px" cellpadding="20px"
style="background:#8df981;">
<tr>
<td bgcolor="#0500fa">
<div style="background:#FFFFFF;">cell content</div>
</td>
<td bgcolor="#0500fa">
<div style="background:#FFFFFF;">cell content</div>
</td>
</tr>
</table>
cell content | cell content |
* : is from cellspacing
* : is from cellpadding
Check the difference. We have set the table background to light green color, so all the cellspacing is viewed in light green as it is the space between cells. The blue sections are the spaces created with cellpadding; the space in white is available for the content in table cell.
0 Response to "Cellspacing vs cellpadding - Table attributes comparison"
Post a Comment