Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS font-size : PX vs EM

  • This topic is empty.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #42600
    maxisix
    Participant

    Hey guys ! I’m not sure that i understand why its recommand to use EM more than PX in responsive web design. Can you guys explain me the reason why everybody use EM? thanks !

    #123917
    yeeyang
    Participant
    #123905
    Paulie_D
    Member
    #125362
    LWTBP
    Member

    I think it’s a fun discussion to ‘start it all up again’ because of what I read here: [Beginner’s Course on HTML CSS by Shay Howe](http://learn.shayhowe.com/html-css/typography “Beginner’s Course on HTML CSS by Shay Howe”)

    Scroll to the portion on text sizes. That course’s advanced course was suggested by Chris so I assume the Basic one holds water too.

    #125366
    Andy Howells
    Participant

    Just to add a little extra to this, I use REM’s instead of EM’s as the math gets complex using EM’s.

    REM’s base themselves on the HTML font-size. So nested font-sizes don’t get exponentially bigger/smaller/more complex.

    If you use SASS/SCSS – don’t go alone, take this Mixin;


    @mixin font-size($sizeValue){
    font-size: $sizeValue + px;
    font-size: ($sizeValue / 10) + rem;
    }

    // To use it;

    html { font-size: 10px; } // or whatever size you want

    .element { @include font-size(14); }

    //This outputs;

    .element {
    font-size: 14px;
    font-size: 1.4rem;
    }

    #125401
    Dami
    Participant

    > REM’s base themselves on the HTML font-size. So nested font-sizes don’t get exponentially bigger/smaller/more complex.

    Thank you! I thought it was my imagination the first time I saw that happening. I hate using EMs just for that reason.

    #125438
    LWTBP
    Member

    > joshuanhibbert

    Yes, I will read everything on that link.

    #125441
    Andy Howells
    Participant

    @Dami – Only thing to watch out for with REM’s is that IE8 and below don’t support them, so make sure to use a PX fallback, placed before the REM in the code, just in case.

    #125440
    Paulie_D
    Member
Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘CSS’ is closed to new topics and replies.