Hot Koehls
  • Email
  • Feedburner
  • Linkedin
  • Twitter
  • Home
  • About
  • Archives
  • Contact
  • Software
    • S3imple Backup
    • Twitter Feed Archiver
    • FileTime
    • Flickr API Demo
Search
Home» For everyone » And a Dim Bulb Brightens…

And a Dim Bulb Brightens…

Posted by Frank - March 28, 2008 - For everyone, For techies
3

Though developer by trade, I think I can talk CSS fairly intelligently with any hardcore designer. But the one thing that always eluded me a bit was the “em” sizing element. I could never find a definitive description of just how the hell they actually worked.

Today I put that one to bed, thanks a straightforward article on A List Apart…

Working from a default of 16px, the following styles should give the desired text sizes:

.bodytext p {
      font-size:0.875em; /* 16x.875=14 */

}.sidenote {
      font-size:0.75em; /* 16x0.75=12 */

}

If you want to work with em’s, your sizes are all relative to 16 pixels. Simply multiply the size by 16 to get the actual display size.

Be sure to convey your “Well, duh!” reactions in the comments.

Update: When it rains it pours. Playing with my newfound logic, I’ve also learned that you can adjust what an em is relative to based on different font-size definitions in nested page elements. Take this simple example…

<div style="font-size:0.5em" />
  <div style="font-size:1.5em" />
    What size is this?
  </div>
</div>

The text in between the two div tags will actually work out to be 0.75em (0.5 x 1.5 = 0.75), which is equal to a pixel size of 12 (see quote above). Now I gotta learn to play carefully with these things…

css

3 comments on “And a Dim Bulb Brightens…”

  1. Matthew Apsokardu says:
    March 31, 2008 at 2:28 pm

    Hey, nice blue focus boxes you got there.

  2. BMorse says:
    March 31, 2008 at 2:47 pm

    “Though designer by trade…”
    I think you meant to say “developer”. Other than that great post.

  3. Frank says:
    April 11, 2008 at 11:46 am

    Alright, fixed the typo. I definitely don’t want to be associated with *you* people. ;-)

Cancel Reply

Categories

  • For entrepreneurs
  • For everyone
  • For techies

Latest Tweets

  • The PA Report - LucasArts' eulogy reminds us of the inhuman cost of game development http://t.co/vVjHkmr9YD
    April 9, 2013 - 2:46 pm
  • Pictures from a developer's life http://t.co/s75fBPTu4v
    April 5, 2013 - 11:44 am
  • Chuck+Norris http://t.co/awBqZ8gncS
    March 7, 2013 - 10:46 pm
  • Google Hacks http://t.co/ZIU2CHcoem
    March 3, 2013 - 1:08 am

Recent Comments

  • Rohitash on Automating SSH or SFTP in scripts
  • kgiFozzkjk on MySQL founder Michael Widenius concerned about sale to Oracle
  • purusjap on Jeff Atwood still wrong about PHP
  • OTHER FUNCTION on Get HTTP status code of cURL call in PHP
  • CounterSpace on Change timezone to GMT in Debian

Recent Posts

  • Display line numbers in WebSVN file detail view
  • It’s dangerous to go alone
  • Create Self-Signed Wildcard SSL Certificate
  • What comes after the yottabyte?
  • Write code like they do in Hollywood
(c) 2012 Frank Koehl. All Rights Reserved.
  • Contact Us
  • Sitemap