The Problem With Em-Based Layouts

I was recently working on a project and thought it might be interesting to try out an em-based layout (where the layout of the entire site changes based on the font size.) I was hoping to preserve ideal line-length for my copy. The geek cred associated with em-based layouts was also appealing–earlier this year it seemed like they were all the rage. This trend may have been kicked off by the brilliant Mr. Dan Cederholm, a personally hero of mine in the web development community–as silly as that may sound.

It occurred to me, however, that there’s a fundamental flaw in the logic of an em-based layout. As a visitor increases the size of the text on screen, the layout will increase in width so that everything remains in proportion. Now I’m generalizing here, but if a visitor needs to bump up the text size to read it, it’s possible (perhaps even likely) that they could be older and potentially less technical than us web developers with our 20+ inch monitors. As the text size (and therefore layout width) increases, these users with their smaller monitors will run out of room to grow pretty quickly. This causes dreaded horizontal scrolling which no one likes, no matter what designers may have told you in the late 90s.

Roger Johansson acknowledged this flaw on his blog and suggested that by setting a maximum width in pixels you could prevent this issue. The problem that is titular to this post, though, is that this just doesn’t seem to work. It’s possible that it did work at one time, but I’ve tested many layouts online in addition to my own test case and found that in recent versions of Firefox the layout expands unchecked, causing horizontal scrolling. Perhaps this feature was broken during recent updates to Mozilla’s rendering engine. Unless I’m missing something em-based layouts are self-defeating as it stands. So are they anything more than geek-chic?

Dustin Tigner points out in the comments that something has changed in firefox 3. It now uses page zooming by default. If you enable text-only zooming these layouts start to work again. That begs the question, however: With browsers moving toward page zooming by default, how much longer will em-based layouts be a practical use of our time? I think in some cases page zooming provides a worse user experience than a well-coded em based layout (see http://www.456bereastreet.com/ as an example,) and as a default it tends to override those careful layout considerations.

2 thoughts on “The Problem With Em-Based Layouts

  1. Over the last few days, I’ve converted my entire layout to em and found, at first, that it worked rather well. However, I’ve made a few changes to my markup to make it more semantically correct, which only unleashed ongoing problems.

    Your point is very valid. If someone needed to increase the size of the text, it’s likely they are older, using older technology. However, as time passes, this becomes less true.

    With my current design, for whatever reason, I cannot get it to scale down correctly. It’s like the containing div reduces in size more so than its contents, making my objects wrap. I like elastic designs, though I’m now wondering if all this extra time is even needed.

    FireFox 3 does not increase the text size, it zooms in and out. Thus, it doesn’t matter if you design your site in px or em, the site will scale perfectly – including all the images.

    I’m thinking of ditching my em layout and moving back to my good pal px. :o)

  2. I had totally forgotten that Firefox 3 uses page zoom instead of text resizing. Setting it to use text zooming only I can get the layouts to work. I’ll update the post accordingly.

    It seems like browsers are all moving toward page zooming, so I wonder how much longer em-based layouts will even make sense. It’s a clever technique, but the way browsers have implemented page zooming seems to break the most clever implementations.

Comments are closed.