Loading...

HTML essentialsMedia

Favicons & app icons

3 min lesson

Next
  • A favicon is the small icon shown in the browser tab, bookmarks and history.
  • App icons are the larger versions used when a site is added to a phone or desktop home screen.
  • You add a favicon with a <link rel="icon" href="favicon.ico"> tag in the head.
  • Modern browsers also read an SVG icon via link rel="icon" type="image/svg+xml".
  • This builds on SVG, canvas & iframes: SVG icons stay sharp at every size.
  • The example adds an SVG favicon and an apple-touch-icon to a tiny page; you will see the tab icon change.
  • This completes the Media group; your pages can now show text, images, sound, video and icons.
Keep in mind
  • Put a favicon link in the head so every page shows it.
  • Use SVG for crisp modern icons and PNG for older devices.
  • Keep the icon simple: it is tiny, so small shapes read best.
  • After adding it, hard-refresh the browser to see the new tab icon.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Favicon</title>
  <!-- Modern SVG favicon -->
  <link rel="icon" href="icon.svg" type="image/svg+xml">
  <!-- PNG favicon for older browsers -->
  <link rel="icon" href="icon-32.png" sizes="32x32">
  <!-- Touch icon for iOS home screen -->
  <link rel="apple-touch-icon" href="apple-touch-icon.png">
</head>
<body>
  <!-- A tiny page to show the tab icon -->
  <h1>Look at the tab</h1>
  <p>The small icon beside the title is the favicon.</p>
</body>
</html>

What happens: A browser tab titled "Favicon" with the icon from icon.svg shown beside the title, and a page showing "Look at the tab" and the paragraph "The small icon beside the title is the favicon."

Breaking it down

icon svg

<link rel="icon" href="icon.svg" type="image/svg+xml">

Tells modern browsers to use the SVG icon. It stays sharp in every tab size.

icon png

<link rel="icon" href="icon-32.png" sizes="32x32">

A fallback for older browsers that do not read SVG icons.

apple-touch-icon

<link rel="apple-touch-icon" href="apple-touch-icon.png">

The icon iOS uses when someone adds the site to the home screen.

Icon files

FileWhere it appears
icon.svgBrowser tabs (modern browsers)
icon-32.pngTabs and bookmarks (older browsers)
apple-touch-icon.pngiOS home screen
manifest iconsAndroid and desktop apps

A helpful analogy

A favicon is like a name tag at a party: it does not explain who you are, but it helps people spot you quickly. A good name tag is short and clear, and so is a good favicon.

Nesting rules

  • 1.Put icon links inside head, not body.
  • 2.Use the same icon across every page of the site so users can recognize it.

Common mistakes

Missing the icon link on most pages

Avoid

Only the homepage has the favicon link

Use instead

Every page includes the same link in head

Without the link, other pages show a default icon and the site looks unfinished.

Using a very detailed image as a favicon

Avoid

A photo with many colors

Use instead

A simple shape like a single letter or icon

The tab shows the icon very small. Detail is invisible, so a simple shape reads better.

Quick tips

  • •Design the favicon at 16 by 16 pixels first; if it reads there, it will read everywhere.
  • •Hard-refresh the page after adding a favicon; browsers cache it aggressively.
Previous
Next