Forum Moderators: open
If I want a table to have three columns, each 100 pixels wide with a cell padding of 3 does it add up to 106 pixels per column and 318 for a total table width, or is the total table width 300?
If I want to place a 100 pixel wide image in a cell that has a padding of 3, how wide does the cell need to be specified at, 100 or 106?
The first thing to realise with tables is that they are quite difficult to control - at the end of the day the browser will do what it wants!
You're on the right track with your reckoning, but there is also cellspacing to take into account and browser differences!
This code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>: : : Table : : :</title>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1"/>
</head>
<body><table style="background: #999">
<tr>
<td style="padding:3px; width:100px">1</td>
<td style="padding:3px; width:100px">2</td>
<td style="padding:3px; width:100px">3</td>
</tr>
</table></body>
</html>
gives me an entire width of 326px in IE6, Opera and Mozilla with the background set to the table - but 322px with the background set on the <td>...