Where is the default font size declared in the user agent stylesheet?

I know the default font size is 16px, but I can’t find where this is explicitly declared in Firefox’s default stylesheet. I expected to find it in the body element’s ruleset, but it’s not there. I was also wondering how all the em units work, because those are relative to the font size of the element, which isn’t declared anywhere.

Firefox Stylesheet

This is not quite the entire story. The user’s default font size is defined in the browser settings. For FF you can find it in Edit → Settings. Almost all browsers ship with that setting set to 16px but the user can change it to whatever they want. And there is nothing stopping a browser from shipping with a different default font size in the future.

Browser’s will use the default font size set in the settings as the default font size on the page. So basically it’s as if you have the following at the top of the browser’s default style sheet:

* {
  font-size: 1rem;

But you won’t find that explicitly in there because it isn’t needed since that’s how browsers work. What you will find is font sizes set for other elements, such as headings and such, but these will all be in either em or rem units (or other relative values) in order to respect the user’s default font size settings. I doubt (or at least I hope not) you will find a font-size being set in px in any browser’s default style sheet.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.