On this page11 sections
  1. Learning Objectives
  2. 1. Google Material Symbols
  3. 2. Bootstrap Icons
  4. 3. Font Awesome
  5. 4. Size and Colour
  6. 5. Inline SVG Icons
  7. 6. Accessibility
  8. Common Beginner Mistakes
  9. Practice Questions
  10. Practice Answers
  11. Key Takeaways

Lecture 011: Icons

Category3: Text, Fonts & Content
Lecture011 of 057
Estimated video length8 min
TargetCSS3 · any modern browser
LevelBeginner

Icons make interfaces quicker to scan: a magnifier for search, a bin for delete. The easiest way to add them is an icon library that works like a font, so you size and colour icons with the same CSS you use for text.


Learning Objectives

  • Add icons from Google Material Symbols, Bootstrap Icons and Font Awesome
  • Size and colour icons with font-size and color
  • Use inline SVG icons
  • Make icons accessible

1. Google Material Symbols

Add the stylesheet once, then write the icon's name inside a <span>.

Example

html
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined">

<span class="material-symbols-outlined">home</span>
<span class="material-symbols-outlined">search</span>
<span class="material-symbols-outlined">favorite</span>
<span class="material-symbols-outlined">shopping_cart</span>

Browse names at fonts.google.com/icons.


2. Bootstrap Icons

Example

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

<i class="bi bi-house"></i>
<i class="bi bi-envelope"></i>
<i class="bi bi-gear"></i>
<i class="bi bi-trash"></i>

Browse at icons.getbootstrap.com.


3. Font Awesome

Example

html
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">

<i class="fa-solid fa-user"></i>
<i class="fa-solid fa-phone"></i>
<i class="fa-brands fa-youtube"></i>
<i class="fa-brands fa-whatsapp"></i>

4. Size and Colour

Icon fonts behave like text, so font-size and color style them.

Example

html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<style>
  .small { font-size: 16px; color: #868e96; }
  .big   { font-size: 48px; color: #e03131; }
  .btn   { font-size: 16px; padding: 8px 14px; border: 0; border-radius: 6px; background: #1971c2; color: white; }
</style>

<i class="bi bi-heart-fill small"></i>
<i class="bi bi-heart-fill big"></i>
<button class="btn"><i class="bi bi-download"></i> Download</button>

5. Inline SVG Icons

Paste an icon's SVG directly. Using currentColor makes it take the text colour.

Example

html
<style>
  .icon { width: 24px; height: 24px; vertical-align: middle; }
  a { color: #2f9e44; font-size: 18px; text-decoration: none; }
</style>

<a href="#">
  <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
    <path d="M20 6 9 17l-5-5" />
  </svg>
  Done
</a>

SVG icons load with no extra font file and stay perfectly sharp.


6. Accessibility

  • Decorative icon next to text → hide it from screen readers: aria-hidden="true".
  • Icon with no text (an icon-only button) → give the button a name: aria-label="Delete".
html
<button aria-label="Delete"><i class="bi bi-trash" aria-hidden="true"></i></button>

Common Beginner Mistakes

1. Forgetting the library's stylesheet. The icon shows as a word, or nothing at all.

2. Loading three icon libraries. Pick one; each is a large download.

3. Icon-only buttons with no label. Screen readers just say "button".


Practice Questions

  1. How do you make an icon-font icon bigger?
  2. How do you change its colour?
  3. What does fill="currentColor" (or stroke="currentColor") do in an SVG icon?
  4. Write a Material Symbols "settings" icon.
  5. How should an icon-only delete button be labelled?

Practice Answers

  1. Increase its font-size.
  2. Set color.
  3. It makes the icon use the current text colour.
  4. <span class="material-symbols-outlined">settings</span> (with the stylesheet linked).
  5. <button aria-label="Delete">…icon…</button>, with the icon itself aria-hidden="true".

Key Takeaways

  • Icon libraries (Material Symbols, Bootstrap Icons, Font Awesome) work like fonts.
  • Size with font-size, colour with color.
  • Inline SVG + currentColor is light and sharp.
  • Hide decorative icons; label icon-only buttons.