Skip to Content


Public news / March 2007 / Em calculator

Em calculator

Handy Em calculator might save you some time in your daily work.

permanent link 02 mar at 10:42 by schnuck

There are 6 guest comments so far.

commentat 21:46 on 02 March 2007, Anders Tornblad wrote:

This has absolutely no value!

You cannot simply multiply or divide the px value to get the em value. One em unit is the width of the small letter 'm' in the current font. The em-to-pixel ratio varies by so many factors that you should never attempt this.

Try to figure out the difference between 1 em on a WinXP IE6 ClearType rendering 96 dpi system with Verdana, and 1 em on a Mac OS X Safari Antialiased rendering 120 dpi system without the Verdana font installed...

Simply don't mix pixels and em/ex values!

commentat 23:33 on 02 March 2007, Ryan Werth wrote:

Actually Anders, em is not typeface specific, 1em is 1em for all typefaces at any given point size (e.g. 1em in a 12pt typeface is 12 points, period). Also, it is the capital M, not the lowercase, and it is not even necessarily that (that practice comes from printing presses, but is not necessarily the rule in modern foundry fonts or other languages’ fonts).

You are correct however that em to px calculations are dpi dependent. Fortunately, the equation used in the linked calculator works on most systems today. The default font size in most browsers is 16px. IE’s default however is 12pt (which at 92dpi equals out to roughly 16px). However, a windows system running at a higher dpi is not so uncommon anymore … in which case these em to px calculations would be incorrect. So yes, this may be considered a bad practice.

commentat 00:16 on 03 March 2007, Ryan wrote:

"which at 96dpi equals out to roughly 16px"

my bad

commentat 00:36 on 03 March 2007, Bramus! wrote:

62.5% is the magic number to working with ems. From there one just calculate as you would normally do (viz. in a base 10 system, not base 16)

commentat 05:46 on 04 March 2007, David B. wrote:

yeah but 62.5% is so small, on IE sometimes its unreadable. i use 75% or even 95%. then adjust individual elements as needed.

commentat 11:17 on 18 March 2007, Riddle wrote:

Hi

My tool lets you input your browser's default font-size, because all 1st-level calculations depend on this value. So if you're using any modern computer with modern browser, you should be able to use Em Calc and design sites properly without any tweaking.

Anyway, I always set font-size on body as 100% - it makes text size the same in IE / Fx / Opera / Safari etc etc etc. You shouldn't use font-size: 16px because IE won't let you change font-size on your webpage.

BTW, today I released small pack of improvements marked as version 2.1, check them out. :)

Add a comment:

(required, non-public)

  |  Chars left: 1000

Keep the comment relevant, constructive and be polite.
A valid email address or URL to your site must be provided, or the comment might get deleted. Content seemed inappropriate or offensive may be edited and/or deleted. Avoid explicit language and words such as "sucks" and "ripoff". For more in-depth discussions use our forum. Email addresses are never displayed. Line breaks and paragraphs are automatically converted - no need to use <p> or <br/>. Quotes & apostrophes are automatically converted to smart punctuation. Be careful when copying and pasting portions of entries or other comments. The following inline HTML elements may be used: <strong><em><pre><q><blockquote><code>. All other code will get removed before posting. Don't forget to close your tags.


Search the archive

Stylegala news archive

Public news archive

News contributors


Features

Stylegala BookStore
The Stylegala BookStore has a massive archive of great books for you as a professional..
Bullet madness
Bullet madness is a list of 200 bullets, arrows and icons uploaded by our users.
CSS Reference
An alphabetical list over the most common CSS1 and CSS2 syntax and properties.

Sponsors

Logo design for $149

Advertise here