px, em, and zoom

Discussion in 'HTML & Website Design' started by 80r, Feb 24, 2010.

  1. #1
    In short, the question is use px or em?

    I searched this and found a lot of articles preferring em since it allows the user to change the font size. Consequently, however, other elements would have to be set to em or else the text may break outside their boundaries if the text is made large enough.

    But wouldn't using px be more versatile since the user has the option to simply zoom and all the proportions would stay exactly the same as it's designed?
     
    80r, Feb 24, 2010 IP
  2. Rob B

    Rob B Peon

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi there, it is best to use em's when defining a font size.
    The best thing to do would be in your CSS body tag input "font-size:62.5%;"
    then when your defining a text class set the font size to say 1.2em which would then be equivilent to 12px in size, then for all other elements like divs when defining a size you would use pixels and this would prevent the text breakeing from an element.

    hope this helps
     
    Rob B, Feb 25, 2010 IP
  3. pmek

    pmek Guest

    Messages:
    101
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi 80r,

    It's usually best for accessibility to use em or % font sizes. A good article can be read about it, here.

    Also, if you set your body font size to 62.5%, then your font sizes will be similar to pixel sizes. For example, 1.2em is the same as 12px, and so on. Give it a go and see what you prefer!
     
    pmek, Feb 25, 2010 IP