My understanding from reading threads like this one is that the point of ems is to define all measurements in your webpage, by the base font size, which can be set by your browser.
For example, in Chrome you can do this by going settings -> show advanced settings -> web content -> font size: very large
. I might do this if I were using a large, high resolution monitor, that was far away.
I created a plunker that demonstrates the difference between ems and px in sizing.
#div1 {
width: 320px
}
#div2 {
width: 20em;
}
If in my browser I set font size to medium, these divs will be the same size, base font size being 16px, so 20em = 320px.
However, when I change my browser font size up to very large, we can see that the div measured in ems has increased size.
However, this effect will be negated if I define the font size in the body tag for example.
body {
font-size: 16px;
}
Because now my css is overriding the font size set by the browser.
I get that ems would have been important in the days of older browsers, where zooming on the page would only scale up fonts. But these days modern browsers scale up both pixels and fonts, rendering the zoom issue moot.
Looking around the web - a lot of websites do set font size in their body tag.
Stack Overflow for example, sets font-size to 13px in the body tag. Setting font size in my browser doesn't affect the layout of Stack Overflow in the slightest.
Google search results doesn't do this.
(both these screenshots taken with chrome font size set at very large, and 100% zoom).
So perhaps you could argue that setting font size in the body tag, is a bad idea because it prevents a user's own accessibility settings. But given that the user can zoom to increase the sizes (which will proportionally increase all the pixels too) - this doesn't seem like a real problem.
body { font-size: XYZ; }
using a user stylesheet withbody { font-size: ZYX !important; }