The A List Apart Blog Presents:

Magic Numbers and Progressive Enhancement

Article Continues Below

Chris Coyier explains Magic Numbers:

Magic numbers in CSS refer to values which “work” under some circumstances but are frail and prone to break when those circumstances change. They are usually always related to fonts.

Many good examples in that post, and in the comments, but the one that stood out for me was Chris’ attempt to flank a heading with horizontal lines:

In a recent post Line-On-Sides Headers, I used a line-height value that was a magic number. Let’s say you used the technique around text with a fancy @font-face font. Let’s say that font doesn’t load or the user overrides it or the page is being viewed in a browser that don’t support @font-face. The fallback font will load, and that fallback font might have drastically different sizing than the custom font. The lines on the outside of the fallback font are now awkwardly placed, not centered like we wanted.

Of course, I don’t need to tell Chris (he was only trying to illustrate a technique and its shortcomings), but it bears mentioning whenever I get the chance: progressive enhancement is part of typography now. First, style text in a generic way (like, without flanking horizontal lines). Then, if the fonts you intend are active, use WebFont Loader (or Typekit font events) to follow up with rules that depend on the presence (and the dimensions) of those fonts.

No Comments

Got something to say?

We have turned off comments, but you can see what folks had to say before we did so.

More from ALA