← Activities Hub

🔣 Icon Lab

Tiny pictures. Big jobs. Everyone included.

① Icons 101

Icons are tiny pictures that do a job: search, cart, settings. They save space and people spot them fast, but only if everyone can tell what they mean. Here are three ways to put one on a page:

1. Icon font + CDN

Add one line to your <head>, then use an <i> tag with the icon’s class. It works like text, so font-size and color style it. This page uses Bootstrap Icons.

<link rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.2/font/bootstrap-icons.min.css">

<i class="bi bi-heart"></i>

2. Inline SVG

Paste the icon’s SVG code straight into your HTML. Super sharp at any size. Use fill="currentColor" so it takes the text colour.

<svg width="24" height="24"
     viewBox="0 0 16 16"
     fill="currentColor"
     aria-hidden="true">
  <path d="…"/>
</svg>

3. Image file

Save the icon as an .svg or .png and use an <img>. Easy, but you can’t change its colour with CSS.

<img src="images/heart.svg" alt="Like"
     width="24" height="24">

Icon tinkerer

Pick an icon, change its size and colour, then check: is it big enough to tap, and can people see it?

Icon
Colour

        

② Make them accessible

Some people use a screen reader: software that reads the page out loud. It can’t see your icon, so you have to tell it what the icon means. Here are the rules:

Decoration? Hide it.

If there’s text right next to the icon, the icon is just decoration. Hide it from screen readers with aria-hidden="true" so it isn’t read twice.

<button>
  <i class="bi bi-trash"
     aria-hidden="true"></i>
  Delete
</button>

Icon-only button? Label it.

No visible text? Put aria-label on the button. Describe the action (“Close”), not the picture (“X icon”).

<button aria-label="Close">
  <i class="bi bi-x-lg"
     aria-hidden="true"></i>
</button>

Or use hidden text

Bootstrap’s visually-hidden class hides text from eyes but not from screen readers. Same result as aria-label.

<button>
  <i class="bi bi-search"
     aria-hidden="true"></i>
  <span class="visually-hidden">
    Search
  </span>
</button>

Icon on its own means something?

Like a warning sign in a message. Give it role="img" and an aria-label.

<i class="bi bi-exclamation-triangle"
   role="img" aria-label="Warning"></i>

Big enough to tap

WCAG 2.2 says tap targets must be at least 24×24px. 44×44px is even better for fingers. Add padding to small icon buttons.

Easy to see

Icons that carry meaning need a contrast of at least 3:1 against the background. Try it in the tinkerer above! And remember: a hover-only title tooltip is not a label.

What does a screen reader hear?

Same-looking button, five different codes. Press 🔊 Hear it to hear roughly what a screen reader would say.

③ What’s this icon for?

10 icons, 4 answers each. Pick your difficulty! After each answer you’ll see the accessible code for that icon. 🧠

Choose your difficulty

④ Icon libraries

Free icon sets used by real developers. Search, copy, done.

Accessibility reading