What is the em font-size unit? How much is it in pixels?

前端 未结 8 1184
孤独总比滥情好
孤独总比滥情好 2020-12-02 12:30

I want to know what the em unit is, and how much 1em is when converted to pixels (px). I also read somewhere about some IE bug, to overcome which b

8条回答
  •  日久生厌
    2020-12-02 12:57

    Named after the letter "M", the em unit has a long-standing tradition in typography where it has been used to measure horizontal widths. For example, the long dash often found in American texts (--) is known as "em-dash" since it historically has had the same width as the letter "M". Its narrower cousin (-), often found in European texts is similarly referred to as "en-dash".

    The meaning of "em" has changed over the years. Not all fonts have the letter "M" in them (for example Chinese), but all fonts have a height. The term has therefore come to mean the height of the font - not the width of the letter "M".

    From "The amazing em unit and other best practices" https://www.w3.org/WAI/GL/css2em.htm

提交回复
热议问题