Font sizes are computed in pixels. One pixel unit however is not necessarily related to one actual pixel on the screen. One pixel unit on a retina screen might represent 4 actual pixels.

em units are relative to its parent font-size. 0.5em is half the parent font-size. 2em is twice the size.

rem units are relative to the html element's font-size, which if not set defaults to 16px.

If an element other than html overrides its font sizes its child elements using em will be affected, while those using rem will not.

Even though em and rem are calculated based on parent font-sizes, they can be used to set the size of almost anything, just like %, px, vh, etc.