When setting the size of fonts in CSS, should I be using a percent value (%
) or em
? Can you explain the advantage?
Given that (nearly?) all browsers now resize the page as a whole, rather than just the text, previous issues with px
vs. %
vs. em
s in terms of accessible font resizing are rather moot.
So, the answer is that it probably doesn't matter. Use whatever works for you.
%
is nice because it allows for relative resizing.
px
is nice because it's fairly easy to manage expectations when using it.
em
can be useful when also used for layout elements as it can allow for proportional sizing related to the text size.