Solved

cellspacing and cellpadding differences in HTML

Posted on 2010-11-29
5
387 Views
Last Modified: 2012-05-10
Hi,

I would like to know what are differences  between cellspacing and cellpadding in HTML.

i was trying following example
<html>
<body>

<h4>Without cellspacing:</h4>
<table border="1">
<tr>
  <td>First</td>
  <td>Row</td>
</tr>   
<tr>
  <td>Second</td>
  <td>Row</td>
</tr>
</table>

<h4>With cellspacing:</h4>
<table border="1" 
cellpadding="50"
cellspacing="100">
<tr>
  <td>First</td>
  <td>Row</td>
</tr>   
<tr>
  <td>Second</td>
  <td>Row</td>
</tr>
</table>

</body>
</html>

Open in new window

But i could not understand exactly what are the differencs, where to use which one. Any links, ideas, sample code, resources highly appreciated. Thanks in advance
0
Comment
Question by:gudii9
  • 3
5 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 150 total points
ID: 34236192
cellpadding inside the cells
cellspacing outside the cells (between)

http://www.htmlcodetutorial.com/tables/index_famsupp_29.html
0
 
LVL 8

Assisted Solution

by:Zado
Zado earned 200 total points
ID: 34237578
'cellpadding' - you can compare it to regular 'padding' property in html, makes space in cell;
'cellspacing' - you can compare it to 'margin' property in html, makes space around the cell;
 
Read this to understand it better:
http://www.w3.org/TR/html401/struct/tables.html#h-11.3.3
You can learn everything about tables here:
http://www.w3.org/TR/html401/struct/tables.html
 
0
 
LVL 44

Assisted Solution

by:scrathcyboy
scrathcyboy earned 150 total points
ID: 34245342
If you are using tables without border lines, as is often the case, you cannot distinguish between cell padding and cell spacing.  So you are best to use ONLY one or the other, either spacing or padding, to make it easier.  

If the borders of the cells are visible, then it DOES make a difference.  In that case, the padding is the number of pixels "BUFFER" between the text inside the cell, and the cell borders closest to it, left right, top, bottom.  This is the one I prefer to use, as it is easier to keep track of.

Cell spacing -- use it to stretch out the appearance of the table -- but it will also make visible borders to the table cells appear much father apart -- and the table looks rather weird.  Hence use it less.
0
 
LVL 8

Expert Comment

by:Zado
ID: 34317467
Please grant the points and close the question, thanks :-)
0
 
LVL 8

Expert Comment

by:Zado
ID: 34384849
To be clear here: I'm not asking for grant the points to me, but generally.
If you have a problem with any suggestion from experts or nothing works with your expectation, please let us know, so we will continue work on solution for you, thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now