htmlcssfont-scaling

Are rems and ems equivalent when used at root level?


From this answer I see what's the definition of rem in the spec:

rem unit

Equal to the computed value of font-size on the root element. When specified in the font-size property of the root element, or in a document with no root element, 1rem is equal to the initial value of the font-size property.

And the definition of em is:

em unit

Equal to the computed value of the font-size property of the element on which it is used.

To me this implies that 1em == 1rem by definition when used at :root.

Am I correct?


Solution

  • Yes

    :root {
      font-size:40px;
      border-top:   1rem solid red;
      border-bottom:1em  solid green;
    }