paddings or margins

J

Jon Slaughter

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?

http://www.jonslaughter.com/MyPage.html

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 3.2.1.23324 then I'm
not going to worry about it.

Thanks,
Jon
 
B

Ben C

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?

See http://www.w3.org/TR/CSS21/box.html

left only applies to positioned boxes, padding is inside the border,
margin is outside.
http://www.jonslaughter.com/MyPage.html

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

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

Andy Dingley

For my page I used padding to position some elements properly

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 http://brainjar.com/css/positioning/

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,838
Latest member
KandiceChi

Latest Threads

Top