views:

142

answers:

3

I need some info on how to use margins and how exactly "padding" works:

For example: should I put a line to occupate the whole width of the page (no matter what resolution is used to display the web page) letting just a small border on each side, how could I put this?

Thank you!

+9  A: 

Have a look at this: http://redmelon.net/tstme/box_model/

Basically, an element consists of content, surrounded by its padding, then the border, then the margin. Background images only extend as far as the border. Margins are best described as 'the whitespace around this element'.

But have a look at the URL above, and make yourself a test page to have a play with, it should all make sense.

Dan
A: 

I think this should do what you want:

<table width="100%" cellpadding="5">
  <tr>
    <td>
One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... 
    </td>
  </tr>
</table>

Setting width to "100%" forces the text to use the full width, and setting cellpadding to "5" sets a unvisible border of 5 pixels.

koschi
padding isn't an html attribute. You're probably thinking of cellpadding ..?
Dan
You are totally right, Dan, I have been thinking of cellpadding. But (this shall be no excuse) the html code above did the job using the IE.
koschi
A: 

Another way to illustrate it is in the box model, padding is the inside "margin" of a box margin is the buffer around the box.

Crad