Favicons and App Icons
The small icon in a tab, and the larger ones a device uses when a site is saved to a home screen. A short modern set replaces the twenty file mess of a decade ago.
-
HTML Basics
- What is HTML: The Structure Layer of Every Web Page
- HTML Document Structure: DOCTYPE, html, head and body
- Elements, Tags and Attributes: The Vocabulary of HTML
- HTML Comments: Notes That Ship With Your Code
- Block Level and Inline Elements
- Writing and Running Your First HTML Page
- How a Browser Turns Markup Into a Page
- Text and Formatting
- Links and Navigation
- Images and Media
- Lists
- Tables
-
Forms
- Form Structure: form, action and method
- Input Types: Text, Email, Number, Date and the Rest
- Labels: The Most Important Element in a Form
- Checkboxes, Radio Buttons and Grouping
- select, option, optgroup and datalist
- textarea, File Uploads and Hidden Fields
- Buttons: submit, reset and button
- Built In Form Validation
- GET or POST: What Happens When a Form Is Submitted
- Semantic HTML
- HTML5 Features
- Head and Metadata
- HTML with CSS
- HTML with JavaScript
- Accessibility
-
HTML SEO
- How Google Works: Crawling, Indexing and Ranking
- SEO Friendly HTML Structure
- Titles and Descriptions That Earn Clicks
- Headings and Content Structure for Search
- Internal Linking and Anchor Text
- robots.txt and XML Sitemaps
- Canonical URLs and Duplicate Content
- Structured Data and JSON-LD
- Image SEO
- Core Web Vitals and Mobile Friendliness
- DevTools and Debugging
- Editor Productivity
- HTML Best Practices
- HTML Projects
- Advanced Projects
- Practice and Exams
Concept
A favicon is the small image beside a page title in a browser tab, a bookmark, a history entry and the address bar. It is the only visual identity a site has when it is one of twenty open tabs, which makes it worth more than the two lines it takes.
The topic has a reputation for being messy, because for years every platform wanted a different file at a different size. The current answer is much shorter.
The modern minimum
<link rel="icon" href="/favicon.ico" sizes="32x32">
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="manifest" href="/site.webmanifest">Four lines and four files, and that covers every current browser and platform.
| File | Size | Used by |
|---|---|---|
favicon.ico | 32 by 32 | Older browsers, and the automatic request to the site root |
favicon.svg | Any | Current browsers. Scales, and can adapt to dark mode. |
apple-touch-icon.png | 180 by 180 | iOS home screen |
icon-192.png, icon-512.png | 192 and 512 | Android home screen, via the manifest |
The SVG favicon
One file at every size, usually under a kilobyte, and it can respond to the reader colour scheme - something no raster icon can do:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
<style>
.mark { fill: #1e3a8a; }
@media (prefers-color-scheme: dark) {
.mark { fill: #93c5fd; }
}
</style>
<rect class="mark" x="4" y="4" width="24" height="24" rx="6"/>
</svg>A dark blue mark on a light browser interface, a light blue one on a dark interface, from a single file.
Why favicon.ico is still there
Browsers request /favicon.ico from the site root automatically, whether or not a link tag exists. Not having the file produces a 404 in the server log on every fresh visit. Keeping one at the root is the simplest way to stop that.
The ICO format can hold several sizes in one file, which is why 16 by 16 and 32 by 32 are usually packed together.
The web app manifest
<link rel="manifest" href="/site.webmanifest">{
"name": "Riverside College",
"short_name": "Riverside",
"icons": [
{ "src": "/icons/icon-192.png", "sizes": "192x192", "type": "image/png" },
{ "src": "/icons/icon-512.png", "sizes": "512x512", "type": "image/png" },
{ "src": "/icons/icon-maskable.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" }
],
"theme_color": "#1e3a8a",
"background_color": "#ffffff",
"display": "standalone",
"start_url": "/"
}The maskable icon deserves a note. Android crops home screen icons to whatever shape the launcher uses - a circle, a rounded square, a squircle. A maskable icon is designed with the artwork inside the middle eighty percent so that any crop still looks right. Without one, a logo can be cropped through its own edges.
Design rules
- Simplify. At sixteen pixels a detailed logo is a smudge. Use a single letter, a monogram, or the simplest shape from the brand.
- High contrast. It sits against light and dark browser interfaces.
- Keep it square, with the mark centred.
- Test at real size. Zoom a browser tab to see what a reader actually gets.
- Do not use a photograph. Nothing photographic survives sixteen pixels.
Other icon links
<!-- a specific size -->
<link rel="icon" type="image/png" sizes="96x96" href="/icons/icon-96.png">
<!-- pinned tab in Safari, a single colour SVG -->
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#1e3a8a">
<!-- Windows tiles, largely historical -->
<meta name="msapplication-TileColor" content="#1e3a8a">
<meta name="msapplication-config" content="/browserconfig.xml">The long lists of icon links found in older templates are mostly obsolete. The four line set above is enough.
Caching
Favicons are cached aggressively, sometimes beyond a normal cache clear. After changing one, a hard reload may not be enough - the reliable way to check is a private window or a query string on the URL:
<link rel="icon" href="/favicon.svg?v=2" type="image/svg+xml">Important rules
- The browser requests
/favicon.icofrom the root whether you link it or not. - Link tags may point anywhere; the root file is a fallback.
- SVG favicons are supported by current browsers and ignored by older ones, which fall back to the ICO.
- The Apple touch icon should be 180 by 180 with no transparency; iOS renders transparent areas as black.
- Android icons come from the manifest, not from link tags.
- Favicons are cached hard.
Common mistakes
- No favicon at all, so every tab shows a generic placeholder and the log fills with 404s.
- Using a full logo, unreadable at sixteen pixels.
- A transparent Apple touch icon, rendered on black.
- Copying a twenty line icon block from a generator without knowing what any of it does.
- No maskable icon, so Android crops through the artwork.
- Assuming a changed favicon appears immediately.
- An icon that vanishes against a dark browser interface.
Best practices
- Ship the four line set: ICO, SVG, Apple touch icon, manifest.
- Design a simplified mark specifically for small sizes.
- Use the dark mode media query inside the SVG.
- Include a maskable icon in the manifest.
- Keep
favicon.icoat the site root. - Add a version query string when replacing one.
- Check the result in a private window on both a light and a dark interface.
Practice
- Create an SVG favicon that changes colour in dark mode and confirm it in both schemes.
- Write a manifest with three icon entries including a maskable one.
- Take a detailed logo, simplify it to something legible at sixteen pixels, and compare the two in a tab.
- Change a favicon and try to see the change without a private window. What did it take?