Sobes.tech
Middle

Where does the browser get the default font-size value for REM and where can it be overridden?

sobes.tech AI

Answer from AI

The browser takes the default font-size value for the rem unit from the root element of the document — usually the <html> tag. By default, this value is 16px unless overridden by styles.

To override the base font size from which 1rem is calculated, you can set the CSS font-size property for the html selector. For example:

html {
  font-size: 18px; /* now 1rem = 18px */
}

Thus, all sizes specified in rem will scale relative to this value.

Where does the browser get the default font-size… - sobes.tech