What is an EM?
Wikipedia puts it well:
"An em is a unit of measurement in the field of typography, equal to the size of the current font." If your font-size is at 16 pixels, then 1em = 16px
What is the text sizing difference between PX, EM, %, PT?
Pixels and points are static measurements, but commonly used in different mediums. Pixels are used on screens because screens are measured in pixels. Although points can be used on screen, they are the standard in printing because they are a factor of DPI.
Percent and EMs on the other hand are relative measurements. The size of an EM or percentage unit depends on its parent. If body text is sized at 12 pixels, then text set at 120% or 1.2 EM inside the body will be 1.2 * 12, or 14.4 pixels.
How do I convert between PX, EM, %, and PT?
Assuming you aren’t using PXtoEM.com to keep it simple, here are the formulas PXtoEM.com uses.
Note: 16px is used as the body text size in all conversions because that is the browser default. You will change 16px to your base text size.
- PX to EM
- Formula: size in pixels / parent size in pixels
- Example: 12px / 16px = .75em
- PX to %
- Formula: size in pixels / parent size in pixels * 100
- Example: 12px / 16px * 100 = 75%
- PX to PT
- Formula: size in pixels * (points per inch / pixels per inch)
- Example: 16px * (72pt / 96px) = 12pt
- EM to PX
- Formula: size in EMs * parent size in pixels
- Example: .75em * 16px = 12px
- EM to %
- Formula: size in EMs * 100
- Example: .75em * 100 = 75%
Why size your text with EMs in CSS?
Style sheets that use EMs are easier to maintain for the designer (especially with PXtoEM.com at your side) and more accessible to end-users.
Style sheets become easier to maintain because all text set in EMs scale to the body font-size. Only one element\'s font-size needs to change instead of individually changing the font-size of each element.
Accessibility is increased for end-users because text is scaled based on their preferences rather than set statically in pixels. Additionally, end-users can use hot keys to scale the text in all browsers. Many people have difficulty reading small text on a computer screen.
This PX to em concept is copied from http://pxtoem.com/