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
Solved

cellspacing and cellpadding differences in HTML

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses four methods for overlaying images in a container on a web page
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 receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

837 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