We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10746
    • 126 Posts
    Quote from: rthrash at Dec 06, 2006, 03:16 PM

    1em doesn’t actually = 10px. Here’s a good bit of CSS that makes font sizes behave consistently and also cleans some stuff up in general:

    /* Neutralize styling: 
       Elements we want to clean out entirely
       and we reset the base font-size to 10px:
    ---------------------------------------------------------------- */
    html, body, form, fieldset {
            margin: 0;
            padding: 0;
            font-size: 100%;
            line-height: 1.5;
            font-family: Arial, Helvetica, sans-serif;
    }
    html { 
        font-size: 100.01%; /* avoids obscure font-size bug */
        height: 100%;
        margin-bottom: 1px; /* avoid jumping scrollbars */
    } 
    body { 
        font-size: 62.5%; /* 10px ... 68.75%=11px 75%=12px  81.25%=13px  87.5%=14px*/
        height: 100%;
        text-align: center;
    }
    


    OK, returning to this issue again (after wrestling with various other issues..)

    I cannot understand how this code "sets the font size to 10px" ... does this rely on the user setting "16px" as the default font size in their browser? (one of the two references mentioned in this thread alluded to this ..)

    I am having real problems on one of my Linux machines with all the fonts looking horrible, and different to my OTHER Linux machine where they look OK. On my Mac they all look fine no problem.

    Thx

    Gordon
    • The font size normalization to 10px does in fact assume that web surfers have not altered their default font size from 16px.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me