“Touch icons” are the favicons of mobile devices and tablets. Adding them to your web page is easy, and I’m sure you already know how this works using HTML:

<!-- In its simplest form: -->

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

It’s a shame Apple didn’t just implement the standard <link rel=icon> and chose to come up with a more verbose proprietary link relation instead. Chrome v31+ for Android does support this syntax, though! Use it as follows:

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

If no such HTML is found, Chrome for Android falls back to the Apple touch icons instead. Update: As of Chrome 30+, this is no longer true: apple-touch-icon-* is no longer fetched automatically, since the 404 pages that are usually returned were consuming 3-4% of all mobile bandwidth usage. For the time being it is still downloaded when the appropriate <link> HTML is present, though.

Apple iOS has supported touch icons since iOS 1.1.3. What’s weird is that Android 2.1+ also has apple-touch-icon support (with a few quirks).

For web pages that don’t specify a custom touch icon, a thumbnail screenshot of the page is used instead. Android has a default icon, and some systems fall back to the favicon if it’s available.

Fancy effects

iOS automatically adds some visual effects to your icon so that it coordinates with the built-in icons on the Home screen (as it does with application icons). Specifically, iOS adds:

Rounded corners

Drop shadow

Reflective shine

As of iOS 2.0, you can prevent the addition of these effects by using the precomposed keyword:

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

Since the rel attribute accepts a space-separated list of values in HTML, theoretically it should be possible to fall back to the regular icon with added effects for iOS 1 without requiring an extra <link> element:

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

In practice, however, it doesn’t work that way. iOS 4.2 seems to ignore the entire declaration if you’re using the space-separated value technique.

I’d recommend to always use precomposed icons. It gives you full control over your icon, and it’s the only kind of icon Android 2.1 supports. As of iOS 7, no special effects are applied to touch icons anymore, so if you only care about iOS 7 and up you don’t have to use precomposed anymore.

Different icon sizes

The Icon and Image Sizes section in the iOS HIG states that you should create the following icons:

one that measures 76 × 76 pixels for iPad and iPad Mini models with a 1× display;

one that measures 120 × 120 pixels for iPhone 4s, iPhone 5, iPhone 6 (which have a 2× display);

one that measures 152 × 152 pixels for iPad and iPad Mini models with a 2× display;

one that measures 180 × 180 pixels for iPhone 6 Plus (which has a 3× display).

Update (June 2013): As of iOS 7, the recommended touch icon size for Retina-display iPhones went up from 114 × 114 pixels to 120 × 120 pixels. The icon size for Retina-display iPads went up from 144 × 144 pixels to 152 × 152 pixels. This post has been updated to reflect that.

Update (September 2014): This post has been updated once again now that iOS 8 and the iPhone 6 Plus have been released.

It’s perfectly possible to just create one high-resolution icon and use that for all devices. In fact, this is how Apple does it. Devices with smaller screens or lower display resolutions automatically resize the icon. The downside is that these devices load the large high-quality image, while a much smaller file would have worked just as well. This wastes bandwidth and affects performance negatively for the end user whenever the site is added to the home screen.

Luckily, as of iOS 4.2 it’s possible to specify multiple icons for different device resolutions by using the sizes attribute:

<!-- For non-Retina (@1× display) iPhone, iPod Touch, and Android 2.1+ devices: -->

<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-precomposed.png"><!-- 57×57px -->

<!-- For the iPad mini and the first- and second-generation iPad (@1× display) on iOS ≤ 6: -->

<link rel="apple-touch-icon-precomposed" sizes="72x72" href="apple-touch-icon-72x72-precomposed.png">

<!-- For the iPad mini and the first- and second-generation iPad (@1× display) on iOS ≥ 7: -->

<link rel="apple-touch-icon-precomposed" sizes="76x76" href="apple-touch-icon-76x76-precomposed.png">

<!-- For iPhone with @2× display running iOS ≤ 6: -->

<link rel="apple-touch-icon-precomposed" sizes="114x114" href="apple-touch-icon-114x114-precomposed.png">

<!-- For iPhone with @2× display running iOS ≥ 7: -->

<link rel="apple-touch-icon-precomposed" sizes="120x120" href="apple-touch-icon-120x120-precomposed.png">

<!-- For iPad with @2× display running iOS ≤ 6: -->

<link rel="apple-touch-icon-precomposed" sizes="144x144" href="apple-touch-icon-144x144-precomposed.png">

<!-- For iPad with @2× display running iOS ≥ 7: -->

<link rel="apple-touch-icon-precomposed" sizes="152x152" href="apple-touch-icon-152x152-precomposed.png">

<!-- For iPhone 6 Plus with @3× display: -->

<link rel="apple-touch-icon-precomposed" sizes="180x180" href="apple-touch-icon-180x180-precomposed.png">

<!-- For Chrome for Android: -->

<link rel="icon" sizes="192x192" href="touch-icon-192x192.png">

A few simple rules apply here:

If there is no icon that matches the recommended size for the device, the smallest icon larger than the recommended size is used.

If there are no icons larger than the recommended size, the largest icon is used.

If multiple icons are suitable, the icon that has the precomposed keyword is used.

But it gets more complicated. Pre-4.2 versions of iOS simply ignore the sizes attribute, so the above code snippet would be interpreted as:

<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-precomposed.png"><!-- 57×57px -->

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

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

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

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

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

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

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

Only the last value in the document will be used on those systems. In this case, that’s the largest icon. Depending on how you look at it, it might be better to reverse the order of icons:

<!-- For Chrome for Android: -->

<link rel="icon" sizes="192x192" href="touch-icon-192x192.png">

<!-- For iPhone 6 Plus with @3× display: -->

<link rel="apple-touch-icon-precomposed" sizes="180x180" href="apple-touch-icon-180x180-precomposed.png">

<!-- For iPad with @2× display running iOS ≥ 7: -->

<link rel="apple-touch-icon-precomposed" sizes="152x152" href="apple-touch-icon-152x152-precomposed.png">

<!-- For iPad with @2× display running iOS ≤ 6: -->

<link rel="apple-touch-icon-precomposed" sizes="144x144" href="apple-touch-icon-144x144-precomposed.png">

<!-- For iPhone with @2× display running iOS ≥ 7: -->

<link rel="apple-touch-icon-precomposed" sizes="120x120" href="apple-touch-icon-120x120-precomposed.png">

<!-- For iPhone with @2× display running iOS ≤ 6: -->

<link rel="apple-touch-icon-precomposed" sizes="114x114" href="apple-touch-icon-114x114-precomposed.png">

<!-- For the iPad mini and the first- and second-generation iPad (@1× display) on iOS ≥ 7: -->

<link rel="apple-touch-icon-precomposed" sizes="76x76" href="apple-touch-icon-76x76-precomposed.png">

<!-- For the iPad mini and the first- and second-generation iPad (@1× display) on iOS ≤ 6: -->

<link rel="apple-touch-icon-precomposed" sizes="72x72" href="apple-touch-icon-72x72-precomposed.png">

<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->

<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-precomposed.png"><!-- 57×57px -->

This way, older iOS versions download the smallest icon instead of the largest one. So, instead of forcing the largest icon to all devices unless they support the sizes attribute (iOS 4.2+), we now serve the smallest icon unless @sizes is supported. In other words, we’re now using progressive enhancement instead of graceful degradation :)

When in doubt, always use this snippet. With support for nearly all iOS versions and devices, and as many different Android versions as possible, it’s the most robust way to add touch icons to your site.

I’ve had several people test this on a Nexus One running Android 2.3 (Gingerbread), and it seems @sizes is not supported there either. However, it behaves differently than old iOS versions: instead of using the last <link> element’s @href value, it will use that of the first <link> element with rel="apple-touch-icon" or rel="apple-touch-icon-precomposed" . In the case of the above code snippet, that’s the largest icon available.

Update (March 2013): I crowdsourced some more tests on Android devices. Using the suggested snippet, Android 4.1.x and 4.2.x on Galaxy Nexus both get the 57×57px icon as long as the default Android browser is used to add the bookmark. Bookmarking from within Chrome causes the touch icons to be ignored. This is fixed in Chrome 27. The bug is also present on Samsung I9100 Galaxy S II devices running Android 4.0.x.

Update (July 2013): As of this commit, Chrome for Android no longer requests apple-touch-icon(-precomposed).png by default (i.e., if such an icon isn’t referred to from the HTML source).

Look ma, no HTML!

If no icons are specified in the HTML, iOS Safari will search the website’s root directory for icons with the apple-touch-icon or apple-touch-icon-precomposed prefix. For example, if the appropriate icon size for the device is 57 × 57 pixels, iOS searches for filenames in the following order:

apple-touch-icon-57x57-precomposed.png apple-touch-icon-57x57.png apple-touch-icon-precomposed.png apple-touch-icon.png

That’s right — for iOS, it’s not necessary to use HTML to add touch icons to your site, even if you want to use multiple resolution-specific icons. Say adiós to the boatload of proprietary <link rel="apple-touch-icon"> elements on every single HTML page. Just create different versions of the icon, use the correct file names and place them in the root. ( favicon.ico , anyone?)

So, what do we need?

apple-touch-icon-57x57-precomposed.png or apple-touch-icon-57x57.png for non-Retina iPhone and iPod Touch (@1× display);

or for non-Retina iPhone and iPod Touch (@1× display); apple-touch-icon-72x72-precomposed.png or apple-touch-icon-72x72.png for the iPad mini and the first- and second-generation iPad (@1× display) on iOS ≤ 6;

apple-touch-icon-76x76-precomposed.png or apple-touch-icon-76x76.png for the iPad mini and the first- and second-generation iPad (@1× display) on iOS ≥ 7;

apple-touch-icon-114x114-precomposed.png or apple-touch-icon-114x114.png for iPhone 4+ (with @2× display) on iOS ≤ 6;

apple-touch-icon-120x120-precomposed.png or apple-touch-icon-120x120.png for iPhone 4+ (with @2× display) on iOS ≥ 7;

apple-touch-icon-144x144-precomposed.png or apple-touch-icon-144x144.png for iPad 3+ (with @2× display);

apple-touch-icon-152x152-precomposed.png or apple-touch-icon-152x152.png for iPad 3+ (with @2× display);

apple-touch-icon-180x180-precomposed.png or apple-touch-icon-180x180.png for iPhone 6 Plus (with @3× display);

or for iPhone 6 Plus (with @3× display); touch-icon-192x192.png for Chrome for Android;

for Chrome for Android; apple-touch-icon-precomposed.png and apple-touch-icon.png as a fallback for everything else (possibly including non-Apple devices).

It’s a good idea to include both apple-touch-icon.png and apple-touch-icon-precomposed.png for maximum compatibility: iOS 1 and BlackBerry OS6 don’t support precomposed icons. (Note that Android 2.1 only supports precomposed icons.) You could use rewrite rules to avoid having to duplicate the file.

Sadly, the no-HTML approach doesn’t work on the native Android browser (tested in 2.3 Gingerbread, 3 Honeycomb, 4.1 Jelly Bean), although I’ve had reports saying it does work in and 4.2 Jelly Bean’s default browser. I haven’t been able to test BlackBerry OS6 yet. If you want, you can test this technique on my website. Save a bookmark to this page to your home screen, and see if you get a custom touch icon or not. Please let me know what you find out!

Summary

So, which technique to use? It all depends, really.