Many websites write code that have broken the ability for users to set their own font size (in the settings of the browser/mobile). In order to avoid this, what exactly happens on a technical level when the user changes the default font size? What does it affect?
- the
htmlroot elementfont-sizethat is specified in CSS? Does it scale or override this? - the units
em,px,rem, %? - what about other units, like
vh,vw,vmin,vmaxfor those that are trying to do fluid typography? - how will this affect
calc()? - is the behavior the same for mobile devices?
Notes that don't yet form a full answer:
However, none of the below refer to specifications, but are just collections of specific behaviors.
- From my own experiments, setting
font-sizeforhtmlwith a % does scale when the user changes the browser font size. - This answer has some information, seeming to say that when
htmlis set,pxdoesn't adjust, butem,rem, % do. - This site has some really good info, but it is all a decade old and uncertain if the behavior mentioned is just because of browser bugs or if it's designed that way.
- There is a lot of sloppy language that people use when talking about this. For example, people will talk about the 'base font size', but not specify if this is the font specified in the root/
htmlelement, the browser settings, or the combination of the two. I'm sure it's clear to those who already know the interactions, but to me I still have the concepts unclear.