Padding in table

I am using the following code…

<table border="0"cellpadding=“40” cellspacing=“20” width=“80%” span style=“font-family: Comic Sans MS;”>


<td style=“border: 1px solid black; background: #FEF1B5”>


It works great when I check it out in IE, but when I upload it the padding does not work. I need to add space between text and border of table…??

Not clear - Are you talking about space between text (outside of the table) and the table OR text (with a cell) and the cell border.

Could really do with knowing the context in which the html snippet you have given resides. That is the whole HTML code of the page that holds the snippet.

The text INSIDE the table butts up against the border, and I want spacing between it and the border. I had it okay and did something to affect it.

This is link…see my post from today…

Everything looked OK when I viewed it in Chrome but viewing the source I notice there is no space before cellpadding. I wouldn’t of though this was a problem but it might just be the source of the problem.

All those HTML attributes have been replaced with CSS.

The CSS that most affects the appearance of table cells is border-collapse which can be either separate or collapse

Barnum, this would be a good time to use some basic CSS to save yourself some work. Firstly, change this:

<table border="0" cellpadding="40" cellspacing="20" width="80%" [COLOR="#FF0000"]span[/COLOR] style="font-family: Comic Sans MS;">

to this

<table class="box">

Then add something like this to your style sheet, which you can use over and over just by adding that class to the table:

.box {border:none;
  width: 80%;
  font: "comic Sans MS";

.box td {
  padding: 40px;

In your original code, you have the word “span” (in red) which doesn’t belong there, and may be causing a problem in some browsers.

You should add px after giving the number in the table attributes. e.g <table cellpadding=“40px”></table>

Incorrect. px should not be put into attributes like this. px should only be put into the style attribute.

That being said, the answer provided by ralph.m is the better response. Remove visual display elements out of the HTML, and put it into css.