Solved

cellspacing and cellpadding differences in HTML

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

732 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