Favicon and Apple Touch Icon: sizes, files and code

How to create a favicon and Apple Touch Icon: the sizes and files your website needs, the HTML to add them and how to make the icon look good on iPhone.

3 min readby Luca Ring

A clean favicon setup needs only a few files today: a favicon.ico at 32 × 32 pixels, an SVG for modern browsers and an Apple Touch Icon as a 180 × 180 PNG. The Apple Touch Icon is the image iPhone and iPad show when someone adds your website to the Home Screen.

Without it, iOS falls back to a scaled-down screenshot of the page or a letter. That looks unfinished quickly, and it takes only minutes to fix.

The icon files your website needs

  • favicon.ico (32 × 32): the classic for the browser tab, which older browsers and many tools look for automatically.
  • icon.svg: a vector file that stays sharp at any size and can even adapt to dark mode.
  • apple-touch-icon.png (180 × 180): for the Home Screen on iPhone and iPad, and for bookmarks and previews in Safari.
  • icon-192.png and icon-512.png: for the web app manifest, if your site can be installed as a web app.

Put all files in the root of your website. That way they are found even when a tool never looks at the source code.

Add the favicon and Apple Touch Icon to your HTML

Four lines go into the head of every page:

<link rel="icon" href="/favicon.ico" sizes="32x32">
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="manifest" href="/site.webmanifest">

The manifest is a small text file that lists the larger icons:

{
  "name": "My Website",
  "icons": [
    { "src": "/icon-192.png", "sizes": "192x192", "type": "image/png" },
    { "src": "/icon-512.png", "sizes": "512x512", "type": "image/png" }
  ]
}

Two more tags set the name below the icon and the color of the browser bar:

<meta name="apple-mobile-web-app-title" content="Short name">
<meta name="theme-color" content="#ffffff">

Design the Apple Touch Icon correctly

The Apple Touch Icon has a few quirks that are often missed:

  • No transparent background: iOS fills transparent areas with black. Always give the icon its own background color.
  • Don't round the corners yourself: iOS masks the shape automatically. Deliver a full square.
  • Leave a margin: The artwork shouldn't touch the edge. About a tenth of padding all around looks balanced.
  • Keep it simple: The icon is small on the Home Screen. A clear mark works better than a full wordmark.

Native apps follow their own rules. How layered icons are built there is covered in App icons with Icon Composer.

Test your icons and fix common mistakes

Open your website in Safari on iPhone, tap Share and then “Add to Home Screen”. The preview shows right away whether the correct icon appears.

  • Old icon still showing: Browsers cache favicons for a very long time. Rename the file or add a version, for example ?v=2.
  • Blurry icon: The file is too small. 180 × 180 pixels is the minimum for the Apple Touch Icon.
  • Black background: The PNG is transparent. Export it again with a background color.
  • No icon at all: Check that the file is really reachable at the address you referenced.

If you use a framework like Next.js, it's often enough to place files with fixed names such as icon.png and apple-icon.png in the app folder. The matching head tags are then generated for you.

What else belongs on a good app website is covered in A website for your app. And how to lead visitors straight to your app on the App Store is explained in Smart App Banner in Safari.

  • create favicon
  • Apple Touch Icon
  • Apple Touch Icon size
  • favicon size
  • favicon HTML
  • add website to Home Screen