Solved

cellspacing and cellpadding differences in HTML

Posted on 2010-11-29
5
415 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

717 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