CSS ~ px to em Conversion

541048-64 pxem

I am using Ems [em] instead of pixels [px] in my Twenty Sixteen Theme customized Cascading Style Sheet [CSS]. You ask why?

First, what are the units?

Meet the Units

  1. “Ems” (em): The “em” is a scalable unit that is used in web document media. An em is equal to the current font-size, for instance, if the font-size of the document is 12pt, 1em is equal to 12pt. Ems are scalable in nature, so 2em would equal 24pt, .5em would equal 6pt, etc. Ems are becoming increasingly popular in web documents due to scalability and their mobile-device-friendly nature.
  2. Pixels (px): Pixels are fixed-size units that are used in screen media (i.e. to be read on the computer screen). One pixel is equal to one dot on the computer screen (the smallest division of your screen’s resolution). Many web designers use pixel units in web documents in order to produce a pixel-perfect representation of their site as it is rendered in the browser. One problem with the pixel unit is that it does not scale upward for visually-impaired readers or downward to fit mobile devices.
  3. Points (pt): Points are traditionally used in print media (anything that is to be printed on paper, etc.). One point is equal to 1/72 of an inch. Points are much like pixels, in that they are fixed-size units and cannot scale in size.
  4. Percent (%): The percent unit is much like the “em” unit, save for a few fundamental differences. First and foremost, the current font-size is equal to 100% (i.e. 12pt = 100%). While using the percent unit, your text remains fully scalable for mobile devices and for accessibility.

Pixels are a fixed size and Ems are scalable. Ems are more suitable for mobile devices. I continue to write coding that best shows the blog on mobile devices while maintaining the desktop appearance that is close to what I want. Given that I now use Ems, it seems to be the direction for CSS. OTOH, depending on where one reads, % may be preferred.

I used 16px [recommended] as my base font size. Both Ems & Px are fractions of 16 or whatever the base font size. see this table.

2016-03-22_7-04-23 PX2EM
2016-03-22_7-10-15W3Schools logo

I used an online converter to go from PX-to-EM. Again, I use 16 px as my base. The table and converter graphic are from the  W3Schools.com.

2016-03-22_7-06-45 PX2EM Converter