CoderTools Web site

HTML Table - cellpadding, cellspacing


Description


  • cellpadding - this is used to add space around the inner content of table cells.
  • cellspacing - this is used to add space around the table cells.


Examples

Here is an example where the the cellpadding and cellspacing has been set to 10 pixels:

1 1 1
2 2 2
3 3 3

Here is the code:



Note: You're probably thinking what the hell is this <style> and border-xxx business. Well its C.S.S. or Cascading Style Sheets. Its used here to add a border around the table cells and the table itself. I did not want to start showing you C.S.S. just yet, but the border really helps emphasise colspan, cellpadding and cellspacing. see the css tutorial for more
Example same as before but with no cellpadding i.e. cellpadding="0px" or the cellpadding attribute removed from the code:

1 1 1
2
3 3 3

Note: the border of the cells is very tight around the content of the cells (the 1, 2, and 3 values). Cellpadding add space around the content.
Example same as before but with no cellspacing i.e. cellspacing="0px" or the cellspacing attribute removed from the code::

1 1 1
2
3 3 3
8/17/2017 8:20:58 AM
Terms Of Use | Privacy Statement | Copyright 2006-2015 © Independence Software LLP