px, ems, % - which to use?

Discussion in 'CSS' started by tonytwotime, May 14, 2006.

  1. #1
    Hi guys. Rookie question.

    What are the standards of size/measurement one should be using when building a site? Are there any? For example, both ems and % can be used for padding. What do you guys use for text, padding, margins, etc.?

    Id like to use whatever is interchangable in firefox/IE, if it even exists.

    (P.S. - Im still reading/learning about CSS/Html, and haven't started any new work on my site, so this question could be completely ridiculous. I used some crappy wysiwyg editor to build a website about a year ago, where you don't have to know css/html, or anything else. You just type and click. I wanted to do it right, so thats where Im at right now. :) )
     
    tonytwotime, May 14, 2006 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    Both are supported. IE may give problems from time to time due to the improper/buggy models it follows, but that's a different issue.

    Study the css specs. The basis for computing the end values are different for the two metrics and can cause grief if you don't understand what's going on.

    The differences tend to be philosophical. For example, do you want sizing based on the window size, with the page containers resizing with the user resizing his browser, or do you prefer to base container size on the font size, with sizes remaining proportional to the user's preference in font size?

    There's nothing wrong with fixed px sizes, either. It all comes down to your philosophical approach and the page itself; what's right in that case.

    cheers,

    gary
     
    kk5st, May 14, 2006 IP
  3. tonytwotime

    tonytwotime Guest

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    So, basically, it depends on the situation?
     
    tonytwotime, May 14, 2006 IP
  4. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #4
    That and your attitude. :)

    cheers,

    gary
     
    kk5st, May 14, 2006 IP
  5. penagate

    penagate Guest

    Messages:
    277
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi,

    From the sound of your first post you have absolutely the right attitude :)

    Basically, note that em (font height) and ex (font width) measurements depend on the text size and so will change if the page is zoomed.

    If you're clear on that point then the rest is purely down to your design principle as Gary said.

    - P
     
    penagate, May 15, 2006 IP
  6. AdamSee

    AdamSee Well-Known Member

    Messages:
    422
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    135
    #6
    Personally I use font-size: medium; than percentage width it from there. It's better to use relative units for font-size especially as IE6 can't increase the font-size if it's in px units.
    Ems for lines, paragraph and sometimes if I want some height on a particular layer that contains text.
    Px for certain fixed width and heights
    and percentage width on fluid layouts.

    I rarily touch, ex, pt or other units of measurement
     
    AdamSee, May 15, 2006 IP
  7. penagate

    penagate Guest

    Messages:
    277
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I use pt for text which corresponds to font sizes in most applications and also scales in IE.
     
    penagate, May 15, 2006 IP
  8. AdamSee

    AdamSee Well-Known Member

    Messages:
    422
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    135
    #8
    AdamSee, May 15, 2006 IP
  9. penagate

    penagate Guest

    Messages:
    277
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #9
    That's why modern browsers allow you to change the text size :)

    - P
     
    penagate, May 15, 2006 IP
  10. AdamSee

    AdamSee Well-Known Member

    Messages:
    422
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    135
    #10
    If you want to stick with pt sizes, that's fine. It still doesn't make it a good and accessible unit to use.
     
    AdamSee, May 15, 2006 IP
  11. EWD

    EWD Well-Known Member

    Messages:
    1,688
    Likes Received:
    85
    Best Answers:
    0
    Trophy Points:
    155
    #11
    For better compatibility, use em instead of px as it goes well both with firefox and IE
     
    EWD, May 15, 2006 IP