When setting the font size in CSS, why not set the <body> to 6.25% so that the px and em units are the same?

I read now about how it is good practice to set the font <body>to 62.5%, so later you can use the "divide by 10" conversion from pixel units.

But I was wondering: why not set <body>at 6.25%? You can then use the same sizes for em units as for pixel blocks, provided that the default browser font size is 16 pixels.

eg.

body {
    font-size: 6.25%; /* 1px */
}

p {
    font-size: 12em; /* 12px */
}
+3
source share
3 answers

Two problems.

  • , , , ems, Internet Explorer, .

    , , IE, IE, .

  • , .

    , , , , , ems, font-size , , , - font-size, .

    : , , <li> 12 .

    li {
        font-size: 12em;/* 12px */
    }
    

    HTML-:

    <ul>
        <li>
            <ul>
                <li>
                ...
    

    :

    li li {
        font-size: .083em;/* 12px */
    }
    

    <li> 12 * 12 = 144 !

    . Ems , . , ems , . <body> , , , em. ( , , - .)

    (, , , , IE , , . , .)

+5

: . px . , px.

:
, em ex. 10px, 1.0em 10px, 1.2em is 12px .. . , . div , 20px, 1em , .

. , 62.5% , 10px.
 (, 16 * 0.625 = 10). , Internet Explorer. " ", .

% ( ) . , , . , , 96 . , :

, , , !

:
IE ( 4- , IE7 - ).

.

, CSS, Baseline.

+3

, . -, (1px).

, , , , .

+2

Source: https://habr.com/ru/post/1769564/


All Articles