Results 1 to 6 of 6

Thread: px or em in your css?

  1. #1

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    px or em in your css?

    What do you all use for sizing - font and borders and such?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  2. #2
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: px or em in your css?

    We have a web designer for us now, so I haven't done CSS in ages, but I typically used em for fonts and pixels for everything else.

  3. #3
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: px or em in your css?

    Usually it's a consideration of what is layout (and what kind of layout) vs content. If I haven't made a "liquid" layout (one that will self-adjust to text size changes), then I don't want a site to look broken because someone upped their font size. So in that case, layout elements will likely be pixels.

    For content font, I use a variation of what is discussed in this article: use a percentage as the initial size value, and then ems for the rest.

  4. #4
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: px or em in your css?

    I use ems and px for padding, px for margins, px for borders, px for widths and heights, and neither for font sizing (I use xx-small, x-small, small, medium, large, x-large, and xx-large )

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: px or em in your css?

    em, because px is derived from em. The only reason to use px is when doing absolute positioning (e.g. floating elements with JS).

    This is less of a problem with modern browsers because they all tend to scale elements now rather than simply increase text size.

  6. #6
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: px or em in your css?

    I use px each time the size of the element must be related to a background image. This avoids having a broken layout. Things may change with multiple background images, haven't played around with them a whole lot yet.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width