Solved

cellspacing and cellpadding differences in HTML

Posted on 2010-11-29
5
384 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
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…

743 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

10 Experts available now in Live!

Get 1:1 Help Now