em vs px

CSS to half of a character

The most confusing part of CSS styling is that font-size attribute i.e. how this will show in various resolutions.

em: This scalable unit is used in web document media due to scalability and their mobile-device-friendly environment. For instance one em is equal to current font-size i.e. if font-size of the document is 10pt then 1em is equal to 10pt and 2em is equal to 20pt etc.

px: This is fixed-size units i.e. one pixel is equal to one dot on the computer screen. So it does not scale upward for visually-impaired readers or downward to fit mobile devices.

Leave a Reply

Your email address will not be published. Required fields are marked *