Skip to content

Instantly share code, notes, and snippets.

@wilsonpage
Last active August 29, 2015 14:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilsonpage/b3e4aabf0483ac8f83ff to your computer and use it in GitHub Desktop.
Save wilsonpage/b3e4aabf0483ac8f83ff to your computer and use it in GitHub Desktop.
.icon-foo:before {
font-family: 'icons';
content: 'foo'
}
<span class="icon-foo"></span>
[data-icon]:before {
font-family: 'icons';
content: attr(data-icon);
}
<span data-icon="foo"></span>
@matthew-andrews
Copy link

SVG

@wilsonpage
Copy link
Author

@matthew-andrews how do you colour/style SVG's using CSS?

@ebidel
Copy link

ebidel commented Aug 7, 2014

For CSS properties that inherit (color, fill, stroke-width,...) you can stylize SVG icons. We do this in Polymer's icon svg icon set: http://www.polymer-project.org/docs/elements/icons.html#styling-with-css

@andydavies
Copy link

One limitation of icon fonts is that if a user with accessibility needs forces their own font e.g. a dyslexic uses a special font, then the desired icons won't appear and will be replaced with what ever glyph matches in the user font

@Ianfeather
Copy link

@wilsonpage colour them with sprites, or use foreground svg, and css. depends on browser requirements

@zachleat
Copy link

zachleat commented Aug 7, 2014

Depends on where you want to manage the icon content: in CSS or in HTML?

Really, the best improvement you can make to your icon font implementation is to add a font load check. I talk about this here: https://github.com/zachleat/fontfaceonload and here https://speakerdeck.com/zachleat/bulletproof-font-icons

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment