CSS - em vs. px

Discussion in 'CSS' started by mushget, Nov 24, 2010.

  1. #1
    Hi everyone,

    I have the impression that Internet Explorer can only use EM's. I also have the impression that em's are normally 16 px, but can very in size.

    Is this true?

    Both ways, how do you define the size yourself?
     
    mushget, Nov 24, 2010 IP
  2. CSM

    CSM Active Member

    Messages:
    1,047
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    55
    #2
    IE can use both, px and em. 1 em = 16px, correct.

    Here is a converter (just Google for px to em).

    http://pxtoem.com/
     
    CSM, Nov 24, 2010 IP
  3. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #3
    'em' is actually the current size of the element, whatever that may be set to. Browsers use 16px as the default now but, if you set a <p> to 12px them em in the paragraph is now equal to 12px.

    Older versions of IE did not scale elements set in px as modern browsers do. This was finally fixed in IE7, I think.
     
    drhowarddrfine, Nov 24, 2010 IP
  4. subdivisions

    subdivisions Well-Known Member

    Messages:
    1,021
    Likes Received:
    40
    Best Answers:
    1
    Trophy Points:
    145
    #4
    EM is relevant to font size. 1em = the width of the letter 'm'. The bigger your font size is for the element, the bigger an EM will be.
     
    subdivisions, Nov 26, 2010 IP
  5. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #5
    Absolutely false on the web.
     
    drhowarddrfine, Nov 26, 2010 IP
  6. anjaneya

    anjaneya Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    What is the point here?? If you change px value of course the size would increase; so what on earth are you trying to do with em anyway?
     
    anjaneya, Nov 28, 2010 IP
  7. anjaneya

    anjaneya Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    @drhowarddrfine -- i totally agree with you -- looks like many DP threads have got useless discussions going on... :x
     
    anjaneya, Nov 28, 2010 IP
  8. WebPageMistakes

    WebPageMistakes Well-Known Member

    Messages:
    91
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    110
    #8
    Reference: w3schools.com/CSS/css_font.asp

    If you use percentage or em the font on the page will adjust to the user's screen resolution and if they choose to use the manual enlarging function in the browser's View menu.

    A fixed font size (px) won't.

    Yes, they could use the magnifing thing, but then they probably will have to horizontal scroll to view the page which is just as bad as dealing with fixed font size. ;)
     
    WebPageMistakes, Nov 28, 2010 IP