Previous Message
Next Message

Padding and divs, basic question

Sent by Christian Heilmann on 20 September 2005 23:11

> If I have a div that is set to 120px wide, and I want to drop some text into
> it, and have that text a few pixels in from the border of the div, is there
> some way to do it without messing with the 120px side of things:
> So that's just fine, but the "Something" is butted right up on the red
> border, I want it in somewhat, but then it changes the width if I use margin
> or padding, and I am betting various browsers deal with this in different
> ways.

Real browsers add the padding to the width, so if you want an element
with a width of 120px and padding you need to substract them:

  padding:0 10px;

Older versions of MSIE make a pig's ear out of that, and you'll need
to hack for them:

Chris Heilmann 
css-discuss [EMAIL-REMOVED]]
List wiki/FAQ --
Supported by --
Previous Message
Next Message

Message thread: