Bear Travis
Icons are visual metaphors that help users navigate an interface.
* Let's start with a working definition. * Icons are visual representations of an idea, that help users navigate a graphical interface. * Paraphrasing the parts I like from Wikipedia * If we go back to the first slide, these cursors help the user maintain the map between their physical mouse location and their virtual screen location. * A kind of "you are here" idea. * Think of them as signposts.<img class='icon' src='icon-cow.png'>
.icon { /* formatting */ }
.icon-cow {
background: url('icon-cow.png');
}
<span class='icon icon-cow'></span>
Vector artwork may not scale cleanly to physical pixels.
High resolution displays make these issues less visible.
@font-face {
name: icon-font;
src: url(icon-font.woff) format(woff);
}
.icon { font-family: icon-font; }
.icon-pig:before { content: 'p'; }
<span class='icon icon-pig'></span>
vs
vs
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 100 100">
<path fill="#DA727E" d="…"/>
</svg>
* Some very quick highlights about SVG
* It is its own xml-based document format. It's similar to HTML, but slightly different.
* It was designed to describe scalable vector artwork.
* Because it has its own format, there are a couple interesting things you can do with it, which we'll get to in a second.
<html>
<p>Some text</p>
<svg [xmlns="http://www.w3.org/2000/svg"]
viewBox="0 0 100 100">
<path d="…" />
</svg>
</html>
* You can use it inline, just drop the svg right into your html
* Note that you still have to refer to the svg namespace
p { color: blue; }
path { fill: blue; }
<img src="rabbit.svg">
.icon-rabbit { background: url(rabbit.svg); }
<defs>
<symbol id="chicken">
<path d="…" />
</symbol>
</defs>
<use xlink:href="#chicken" />
<html>
<svg xmlns:xlink="…">
<use xlink:href="animals.svg#chicken" />
</svg>
</html>
<use xlink:href="animals.svg#chicken" />
.icon-fox { background: url('fox.svg'); }
.no-svg-support .icon-fox {
background: url('fox.png');
}
SVG is your best bet for most cases, especially when coupled with a raster fallback.
Use whatever makes your life easier.
<icon set="animals.svg" name="fox" />