A div inside a table cell has an extra 1px border/spacing?
Posted: Wed, 2008-05-21 21:46
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
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?


Moderator
Posts: 6509
Joined: 2004-05-01
Location: Brisbane
td { padding: 0 }
Posted: Wed, 2008-05-21 22:24
td { padding: 0 }How to get help
tags.
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
My articles | CSS Reference
newbie
Posts: 2
Joined: 2008-05-21
you're a savier man! :)
Posted: Wed, 2008-05-21 23:00
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!
Moderator
Posts: 6509
Joined: 2004-05-01
Location: Brisbane
Auror wrote:I see that
Posted: Wed, 2008-05-21 23:46
Works for me when I apply it to the <td>.
How to get help
tags.
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
My articles | CSS Reference