Forum Moderators: open

Message Too Old, No Replies

Table Dimension Math

What does it add up to?

         

ken_b

11:42 pm on May 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I should know this, but I can't seem to sort it out in my mind.

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?

BlobFisk

8:31 am on May 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey ken_b,

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>...

ken_b

3:41 pm on May 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks