Icon Fonts Are Ruining Your Markup

Icon fonts are great. They’re more scalable than PNGs, they’re re-colorable in CSS, and it’s easier than ever to create them. But most of us are using them wrong, and it’s ruining your markup. Recognize this?

<span class="icon icon-calendar"></span>

This is fast becoming the de-facto standard syntax for inserting icons in your webdesigns. No need to fiddle with weird glyphs. No CSS needed to insert icons, even.


Hold up. The promise of CSS was that we could separate presentation from markup. We could create standardized, semantic and sensible markup, that could then be completely re-skinned solely by replacing a stylesheet. That was the whole point of the CSS Zen Garden. By using nonsense spans with verbose classes, that’s out the window, all in the name of convenience. I too have been bitten by the icon-font bug. I’m into them. I think it’s so great that I can re-color icons with a line of CSS. I like how they zoom, and how they have broader support than SVGs.

But they’re not SVGs. They’re not images. We shouldn’t pretend they were, or that they could ever be as accessible as images are.

Theoretically an icon from a font could be inserted in a semi-accessible way by outputting the actual glyph in the code to ensure copy/paste-ability. You’d also have to make sure to only use an icon that already existed in the unicode-table so screen-readers could make sense of them, thus severely limiting your options as a designer. Need a hamburger menu icon? Sorry, doesn’t exist in the unicode table. Pretty much all the benefits of using an icon font would be out the window at this point.

Rewind for a bit. Take a deep breath and think. Why are you using an icon font in the first place? Easy HiDPI and CSS colorability? Easy to show at multiple sizes? Fair enough.

Now pretend icon fonts didn’t exist, what would you do instead? Use a PNG or GIF as a CSS background, right? You’d treat the graphics as presentational elements. Visual aids. You’d keep it separate from your markup. You’d be able to reskin your whole site with a single stylesheet. You’d keep the markup as simple and semantic as that of the CSS Zen Garden. Hopefully you’d be a good person and worry about accessability where it mattered most: in the structure of your markup.

You can still use icon-fonts and have sensible markup while keeping the presentation separate. But doing so means you can’t rely on those bundled CSS helper classes. You have to do it manually; put in the work. Don’t treat icon-fonts like images. Pretend they’re sprites and keep them in your stylesheet. You’ll thank me.

2 thoughts on “Icon Fonts Are Ruining Your Markup”

  1. Tim says:

    I can’t speak for Windows 8 because I haven’t used it, but fonts look terrible on other versions of Windows compared to the same font in a browser on Mac OS. It seems to vary by font as well. For example, Josephin Sans from Google fonts looks awful in the thin weight. If you select a thicker weight it looks better. The same font on Mac OS looks beautiful. This makes me fear using icon fonts on websites because of how they will render compared to having total control through the use of a PNG.

    1. Joen A. says:

      Windows web-font rendering in general is very disappointing. I used to be a fan of ClearType for its zealous effort to hint fonts to the nearest whole pixel for extreme clarity. But as fonts, especially on the web, have become more abundant, the limitations of this tech are becoming obvious.

      Internet Explorer 11 employs its own font rendering though, which looks as good as that of other platforms. Unfortunately Chrome, Firefox, and even Windows itself doesn’t have access to this font smoothing.

Comments are closed.