A div inside a table cell has an extra 1px border/spacing?

Auror
avatar
rank newbie

newbie


Posts: 2
Joined: 2008-05-21

I think the code says it all:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
     <meta http-equiv="Content-type" content="text/html; charset=iso-8859-2">
     <meta name ="Description" content="LibriPro.pl">
     <meta name="Keywords" content="LibriPro">
     <link href="styl.css" type="text/css" rel="stylesheet">
     <title>LibriPro.pl</title>
     </head>
<body>


<table cellspacing="0" summary="" width="300" height="200" bgcolor="navy" border="0">
<tbody>
  <tr>
    <td>
<div style="width: 300px; height : 200px; background-color : Silver; margin: auto; border: none; padding : 0;"></div>
</td>
  </tr>
</tbody>
</table>

<br><br>


<table cellspacing="0" summary="" width="300" height="200" bgcolor="navy" border="0">
<tbody>
  <tr>
    <td>
<div style="width: 100%; height : 100%; background-color : Silver; margin: auto; border: none; padding : 0;"></div>
</td>
  </tr>
</tbody>
</table>


</body>
</html>

I put a div inside a table. Don't ask why Smiling I just need that.
I need to stretch the div to cover the whole space inside the cell it's located in.
The cell (or the whole table like in the code above) has like 300px x 200px, the div inside has the same dimentions. And there it is. An 1px outline. I can give the div 100% width and height. Still no luck.

Why is that?

I've tried setting all kinds of spacings, paddings and border to zero/none etc. Nothing works.

Is there a solution to this?

Tyssen
Tyssen's picture
rank Moderator

Moderator


Posts: 6509
Joined: 2004-05-01
Location: Brisbane

td { padding: 0 }

td { padding: 0 }

How to get help
Post a link. If you can't post a link, post ALL your code, both HTML & CSS. No server-side code; just the code sent to the browser.
Use tags.
My articles | CSS Reference

Auror
Auror's picture
rank newbie

newbie


Posts: 2
Joined: 2008-05-21

you're a savier man! :)

Thanks a lot.

Still one question though.

This is not a "class" nor is it an "id". I cannot assign a "td padding: 0" to only one cell or only one table on my website, right?
This parameter will make a "0" padding for all the tables on the page?

I see that adding plain style="padding: 0;" to either the cell or the whole table doesn't work.

Why does it work only as "global" parameter?

Thanks a bilion for this!

Tyssen
Tyssen's picture
rank Moderator

Moderator


Posts: 6509
Joined: 2004-05-01
Location: Brisbane

Auror wrote:I see that

Auror wrote:
I see that adding plain style="padding: 0;" to either the cell or the whole table doesn't work.

Works for me when I apply it to the <td>.

How to get help
Post a link. If you can't post a link, post ALL your code, both HTML & CSS. No server-side code; just the code sent to the browser.
Use tags.
My articles | CSS Reference