views:

111

answers:

4

I would like to have space around the content, inside the border of the element.

http://www.w3schools.com/CSS/css_padding.asp

I have used cellpadding which is working pretty good in FF but not in IE. The version of ie that i am using is 7.0.5730.13

I have tried a simple table

<table style="padding:100px" border="1">
    <tr><td >123</td></tr>
    <tr><td>456</td></tr>
    <tr><td> 678</td></tr>
    <tr><td>kzuk</td></tr>
</table>

But the output does not have space at all.. If i am using padding tag at <td>. It is working good. As padding is not working in IE. I used an alternate method.

I have created two dummy rows one on top another on bottom and dummy columns one on right another left and styled them with padding. It is working. Please let me if there is any better method to have space around the content...

+1  A: 

You should use something like this:

<td style="padding: 10px">

CSS style 'Padding' should be applied to td not to table.

Vikash
+1  A: 

Check that your ie is not running on quircks mode, verify that you placed these lines on top of your html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

They will prevent ie from loading quircks mode

Remeber, if you apply a padding to the table, like

<table style="padding: 100px">

This will leave a space between the table and its content, if you want to make space between cells and their content, is like vikrash said, or you may use cellpadding

David Conde
I tried this and works in ie 8!, dunno about 7, but I think it should
David Conde
I would like to have a space between table and its contents. So i need to go for padding at the table level. I have placed the lines that you specified on the top of html, stll it is not giving any space in IE 7.
lucky
+2  A: 

http://www.w3schools.com/CSS/css_table.asp
Table padding is only implemented via a cell (td)

fatnjazzy
+1  A: 

IE does not support padding on a table. I'm guessing you want to do this to have a space between the edge of the table and the content.

You can however have the same result by putting the table in a div (this is cross-browser).

<div style="padding:100px; border: solid black 1px">
  <table border="1" style="border: solid transparent 0px; width:100%">
        <tr><td>123</td></tr>
        <tr><td>456</td></tr>
        <tr><td> 678</td></tr>
        <tr><td>kzuk</td></tr>
    </table>
</div>

The div will mimic the table's outer border.

Edit: This will only work if your table is at 100% width. You can however, restrict the width of the div, but then you'd have to know how wide you want it to be.

<div style="padding:100px; border: solid black 1px; width:300px">
  <table border="1" style="border: solid transparent 0px; width:100%">
        <tr><td>123</td></tr>
        <tr><td>456</td></tr>
        <tr><td> 678</td></tr>
        <tr><td>kzuk</td></tr>
    </table>
</div>
Joeri Hendrickx
Thanku for the reply..I tried this way but i am not able to control the padding on the right side of the table.<div style="padding:50px 100px 50px 100px; border: solid black 1px"> I have changed like this as well. But the space on the right side of table is more than 100px
lucky
I'm sorry, I somehow expected you wanted a full-width table... the div will take up the complete width of the parent, so this approach will only work if your table also has 100% width.
Joeri Hendrickx
No need to be sorry:) Thanks for ur reply and the time spent on it.
lucky