Skip to content
Justice Tech School

Icons

Icons can be emoji (plain text characters), inline SVG, or icon fonts loaded from a stylesheet. Inline SVG is sharp at every size and can take its colour from CSS using fill: currentColor.

Size an icon with font-size (for emoji) or width and height (for SVG). Add an accessible label with aria-label, or hide purely decorative icons with aria-hidden="true".

Example
<style>
  .icon { width: 32px; height: 32px; fill: currentColor; vertical-align: middle; }
  .ok { color: #16a34a; }
  .warn { color: #dc2626; font-size: 28px; }
</style>
<p class="ok">
  <svg class="icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z"/></svg>
  Saved
</p>
<p class="warn">&#9888; Warning</p>

Exercise

Make the SVG take the text colour.

svg {
  fill: ;
}

Quiz Test

Why use fill: currentColor on an inline SVG?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.