paddings or margins

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
For my page I used padding to position some elements properly(I could not
set there position directly cause it just wasn't working right. Setting left
would not work but using padding-left does) and I'm wondering if I should
instead have used margins? Would there be any reason not to using padding
and if so would there be any preference to using margins? Or just I just try
and find a better way?

Maybe someone who has a little free time and doesn't mind could take a look
at the code and see if there is any better way I could achieve the same
effect.  I'm a little worried about sorta hacking things to make it work. It
does work with firefox 2 and IE7 but I'd like it to work with other browsers
if possible(if I would just need to change a little code to make it so).

For example, I use the css attribute height and width but I can also set the
height and width in the html tag directly. Which one do I use? Do I use
both?  (for web browsers that don't use CSS).  Ofcourse if its to much
trouble to make it compatible with netscape navigator then I'm
not going to worry about it.


Re: paddings or margins

Quoted text here. Click to load it


left only applies to positioned boxes, padding is inside the border,
margin is outside.

Quoted text here. Click to load it

Use CSS. If the browser doesn't use CSS it's probably better to let it
decide what heights and widths (sounds, frequencies, ...) to make
things itself.

Re: paddings or margins

Quoted text here. Click to load it

Interesting use of "properly" there.

Stop typing. Read a tutorial. You're not going to get anywhere useful
by just twiddling a property at a time and seeing what happens.

Lie & Bos' book "Cascading Style Sheets" is good, as it O'Reilly's
"Head First HTML with CSS & XHTML".  There's also an excellent CSS
positioning tutorial on /

In general though, leave padding alone and do most stuff with margins.
Remember that vertical margins collapse, sides don't. Be careful if
you ever change the position property. Float isn't intended for what
you seem to think and using it reliably isn't as simple as you might

Site Timeline