Page titles can get cut short when several browser tabs are open. An HTML page can supply a favicon, the small image beside its title that helps readers spot the tab.

A simple square PNG with a bold shape is easier to recognize at tab size than artwork with small lettering. The browser loads the image from the URL in the icon link.

A browser can keep showing an older favicon after the image changes. A new filename gives the replacement icon its own URL.

Steps to add a favicon in HTML:

Use just the filename when the PNG sits beside the HTML page and the page has no <base> element. Otherwise, use the icon's path from the site root, such as /site-icon.png, or its full URL if the base URL changes the scheme, hostname, or port.

  1. Copy your square PNG into the same folder as the HTML page you serve in your local preview.

    The image here is a 32 × 32 pixel PNG named site-icon.png. If that filename is already in use, give the new image an unused name.

  2. Open your HTML file in your text editor.

    The example uses index.html, with a <head> element above the page body.

  3. Insert an icon link with your PNG's path in href immediately before </head>.
    <link rel="icon"
      href="site-icon.png">

    If the page already has a tab icon link, replace it in place.

  4. Save the HTML file.
  5. Open the page from your local preview in a new tab in desktop Chrome.

    The address in the screenshot is http://localhost:8000/index.html.

  6. Verify that the new tab shows the PNG from your icon link next to the page title.

    The new Plant Notes tab shows a blue square with a white diamond.

  7. Verify that clicking the saved rel="icon" link's href in Chrome's View page source for that tab opens your intended PNG.

    In the example, clicking site-icon.png opens the blue square with a white diamond at http://localhost:8000/site-icon.png.

Share this guide