Say, for example, that a sight-impaired user sets his normal font size to 20pt (20 points). If the font size of H1 is 2em - as we recommend - h1 elements will scale accordingly and be displayed in 40 points. If, however, the style sheet sets the font size to be 20pt , there will be no scaling of fonts and the size of headlines will have the same size as the surrounding text.
What I don’t understand is the h1 will be 2x the size of what? Where do you specify the width of “M”?
It will be 2 times the size of whatever the font-size of the parent is. If none of the parents have any font-size defined then it will be 2 times the size of the default UA (user agent) setting. Generally (though historically not always) the default setting in browsers is 16px but this of course may be changed as in the example where a sight impaired reader has changed their default via their browser settings to a much higher size.
So assuming the h1 is not nested in a parent with a different font-size then 2 em would make it 32px unless the user has changed the size or the browser has a differing default. The main point being that in using ems you don’t disrespect the user and your font-sizes are then based on what they want their default to be.
Ems have compounding issues and if you nest em elements then the measurement compunds and gets bigger or smaller each time. That’s why these days its better to use rem for font sizing as that is always based on the root (html) element and not on the immediate parent.
You would not set the size of the font in the parent container, instead, you would set the size of the font relative to the size of the font in the parent. In terms of font sizes, you can think of ems as percents. 1em = 100% of the parent’s font size, .5em = 50%, 2em = 200%, etc.