Why font size does not change?

74,848

hmm, seems to work for me: example

Though, what you might be referring to is little change from enabling/disabling the font-size property. This is because the em for nested elements is relative to their parents font-size. In your instance, the font-size:Xem for the div is relative to the font-size:X% of the body.

If your still getting no change, try setting your body's font-size to a larger percentage to make your div's font larger

Share:
74,848
hiway
Author by

hiway

hello, I am very fond of stackoverflow, let's be friends here.

Updated on April 07, 2020

Comments

  • hiway
    hiway about 4 years

    I want to set font size with em, not px. Here is my code:

    <style type="text/css">
    body{
        font-size: 62.5%;
    }
    
    div{
        font-size: 1.2em;
    }
    </style>
    
    <body>
    <div>hello world</div>
    </body>
    

    I want to set div font size to be 12px, but it looks small than I expect, I disable div style with chrome browser tools, it does not look to have any change. Why and how should I do to make div font size 12px? Thanks.

  • hiway
    hiway about 11 years
    yes, you are right. The change is very little, when I change div to a larger size, it can be detected distinctly.
  • CodingEE
    CodingEE over 2 years
    Thank you for the link example. I am learning to use EM, which I needed to get started. You Rock, Michael, thank you.