paddings or margins

Discussion in 'HTML' started by Jon Slaughter, Mar 23, 2007.

  1. 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
    Jon Slaughter, Mar 23, 2007
    #1
    1. Advertising

  2. Jon Slaughter

    Ben C Guest

    On 2007-03-23, Jon Slaughter <> wrote:
    > 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.
    Ben C, Mar 23, 2007
    #2
    1. Advertising

  3. Jon Slaughter

    Andy Dingley Guest

    On 23 Mar, 12:42, "Jon Slaughter" <> wrote:
    > 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.
    Andy Dingley, Mar 23, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Keith

    Setting margins on an ASP.NET page

    Keith, Nov 4, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    776
    Natty Gur
    Nov 4, 2003
  2. Chris D

    Re: Page Margins on an ASP.NET page

    Chris D, Nov 19, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    361
    Chris D
    Nov 19, 2003
  3. Bill Priess

    Re: Page Margins on an ASP.NET page

    Bill Priess, Nov 19, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    9,686
    Bill Priess
    Nov 19, 2003
  4. John Dalberg

    Setting print margins in asp.net?

    John Dalberg, Oct 12, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    826
    John Dalberg
    Oct 12, 2004
  5. Agix
    Replies:
    7
    Views:
    334
    dorayme
    May 10, 2007
Loading...

Share This Page