pngtoicotool
Browser-only conversion

Favicon HTML

How to Add a Favicon to Your Website with HTML

To add a favicon in HTML, place a <link rel="icon"> element inside the document’s <head> and point href to an icon file your site actually serves. For example: <link rel="icon" href="/favicon.ico">. This link connects the page to an image; it does not create, resize, or convert the image.

1. Choose and publish the image first

Create or select the icon image, then put it in a directory included in your deployed site. The name is up to you. The path in href must match the published file’s actual location.

ICO, PNG, JPEG, GIF, and SVG appear in different favicon workflows, but that does not make them interchangeable in every browser. The HTML relationship remains rel="icon"; a browser can use the declared type, media, and sizes to choose among candidates, and can skip an unsupported resource. Choose a format your target browsers support, then link to that exact file.

2. Put the link in the head

For a root-level ICO:

<link rel="icon" href="/favicon.ico">

For a PNG inside an assets directory:

<link rel="icon" href="/assets/favicon.png" type="image/png">

Use rel="icon" for new markup. The older rel="shortcut icon" spelling appears in existing examples, but adding “shortcut” does not convert the image or fix an incorrect path. The type value should match the image served at href; it is advisory metadata, not an instruction to transform the file.

3. Read size advice in context

A 96-pixel source suggestion and a 500-by-500 source-size objection are not two browser rules. They are different production choices. The HTML sizes attribute describes the icon dimensions available in a resource; it does not resize that resource.

Google Search has separate favicon guidance: the image must be square and at least 8 by 8 pixels, and Google recommends an image larger than 48 by 48 pixels. Those are Google Search eligibility criteria, not a universal minimum for browser-tab icons. Keep the target surface clear before applying a size recommendation.

4. Check the deployed file, not only the editor preview

Save the page and inspect the preview, but treat that as a local check. A preview can resolve a file that the deployed site does not publish at the same path. On the live page, open the exact URL from href and confirm that it returns the intended image; then inspect the page where you expect the icon to appear.

If you move or rename the asset, update href to match. Diagnose the link, the published file, and the displayed icon as separate steps: a correct tag cannot make a missing file appear, and a valid file alone does not tell the page which icon to use.

Add the favicon link in a shared website head

Local fixture run: 2026-10-17. Environment: Windows 11 Pro build 22631, Chrome 155.0.8059.84, and Node.js v24.20.0. A small Node.js HTTP server served `/` and `/nested/page` using the same `shared-head.html` fragment. This test covers that fixture only; no production framework layout was tested.

To find the shared head for a multi-page site, compare the template or layout rendered by its home route and a nested route, then identify the head markup both use. In this fixture, both route handlers inserted `shared-head.html` before `</head>`. Put the favicon link in the shared layout so both routes receive it; a tag added only to one page will not verify the other page.

Chrome opened `/` and displayed `Home fixture`, then opened `/nested/page` and displayed `Nested fixture`. The server log recorded a `GET /favicon.ico` after each page load. The common favicon line in the served head was:

Home page `/` — raw favicon line: `<link rel="icon" href="/favicon.ico" type="image/x-icon">`.

Nested page `/nested/page` — raw favicon line: `<link rel="icon" href="/favicon.ico" type="image/x-icon">`.

The resolved request path was `/favicon.ico` at the fixture's local origin. A direct request returned HTTP `200`, content type `image/x-icon`, and `36,827` response bytes. Those are measurements of the local test server and its probe ICO, not production hosting results.

Not tested: WordPress or another framework's shared layout, any browser besides Chrome, and access over a phone or cellular network. Repeat the two-route check against the layout and public icon URL used by your own site.

A relative filename follows the page URL

A path without a leading slash is resolved relative to the current document. That difference can hide in a site whose home page works while a guide or product page shows a broken icon. In a local browser fixture, the same `href="favicon.ico"` resolved to `/favicon.ico` from a root document and to `/nested/favicon.ico` from a document in `/nested/`.

A leading slash points from the origin root: `/favicon.ico` resolved to `/favicon.ico` in both tested document locations. In the missing-file fixture, the relative path resolved to `/nested/missing.ico` and returned 404. These are measured URL resolutions and HTTP responses from the test server; they are not a promise that every browser cache or hosting configuration behaves identically.

The test used four separate HTML routes, each with a single icon link and no `base` element. The root and nested folders both served the same 36,827-byte probe ICO. That kept the image constant while the document URL or href changed, so the test measured path resolution rather than a difference in artwork or encoding.

For every row, the local script opened a fresh browser context, read the resolved `link.href`, fetched that URL, and recorded its status, response type, and body length. The three valid paths returned the identical ICO as `image/x-icon`; the missing nested path returned a nine-byte plain-text 404. The run therefore isolates URL and server mapping for these fixtures. It does not claim that Chrome displayed the icon in a tab or that a CDN cache was tested.

Check the request before changing the icon

If the file was replaced at the same URL, the browser may still show a cached icon while the new request propagates through your site or CDN. Test the exact deployed URL in a clean browser session. If you control the markup, a versioned filename such as `favicon-v2.ico` gives you a new path to verify without changing the icon format.

Keep this step separate from mobile home-screen icons

A `rel="icon"` link handles the page-icon relationship. It is not a complete instruction for every mobile Home Screen or installed web-app icon. Apple touch icons and web-app manifest entries are separate routes; add them only when that destination is part of your release. This guide covers the browser favicon URL and the HTML element that points to it.

When the link looks right but the icon does not

First identify where the icon is missing. A browser tab reads the page icon link, while a Google Search result follows its own homepage and favicon crawl path. A working icon in one surface does not establish that another surface has refreshed. Google can take several days to several weeks to recrawl and process the homepage and favicon, and display in Search is not guaranteed.

Opening the icon URL confirms that the address returns a resource; it does not confirm that the live page points to that URL or that the browser has stopped using a cached icon. Inspect the rendered home-page head and compare each icon href with the exact file you opened.

If the browser tab is correct but Google still shows an older icon, treat that as a separate refresh path. Repeatedly editing a link that is already correct cannot show that Google has updated its result.

Treat fixes as tests, not universal remedies

Troubleshooting outcomes can differ. A hard refresh can clear a stale browser-tab icon, while switching from a root path to a relative path, adding a PNG fallback, and forcing a reload can still leave the icon unchanged. These actions are tests, not guaranteed fixes.

Renaming a file and redeploying can help distinguish a changed asset at the same URL; clearing browser and CDN caches and renaming the file can also help. If the format, dimensions, sitemap, and indexing settings all change together before the icon appears, the result does not isolate which change mattered. Change one variable at a time and check the same surface after each change.

Choose SVG advice for the surface you are checking

SVG handling depends on the destination. Google Search’s favicon format guidance does not list SVG, and a browser fetching an SVG resource does not prove that the icon rendered in its tab. Identify the missing surface before changing an SVG declaration or replacing the file.

Run the checks in a fixed order

Inspect the live home page’s rendered head and record each icon link. Open the exact href and confirm that it returns the intended image. If the browser tab remains stale, try a private window or hard refresh before changing the file. Then change one thing and recheck that same surface.

For choosing a favicon file format, see the [choosing a favicon file format](favicon-file-format).

ICO, PNG, and SVG favicon markup: one local Chrome run each

The WHATWG HTML Standard defines rel="icon" as a page or site icon link. Its type value is advisory, sizes lists bitmap dimensions available in the file, and sizes="any" marks a scalable icon such as SVG. Those are specification statements, not measurements from this run: WHATWG link type icon.

Local measurement on 2026-10-17: Windows 11 Pro build 22631, Chrome 155.0.8059.84, and Node.js v24.20.0. Each page had one icon link; Chrome's cache was cleared and disabled before each round. The ICO probe was 2,749 bytes with 16 × 16, 32 × 32, and 48 × 48 entries; the PNG probe was 4,288 bytes at 180 × 180; the SVG probe was 380 bytes with a 180 × 180 viewBox. These files and responses came from the local fixture, not this site's production host.

Format and fileExact <head> lineChrome network recordTab display
ICO · 2,749 bytes · 16 × 16, 32 × 32, 48 × 48<link rel="icon" href="/assets/favicon-html/evidence/format-probes/probe.ico" type="image/x-icon" sizes="16x16 32x32 48x48">GET /assets/favicon-html/evidence/format-probes/probe.ico · 200 · image/x-icon · one requestNot measured
PNG · 4,288 bytes · 180 × 180<link rel="icon" href="/assets/favicon-html/evidence/format-probes/probe.png" type="image/png" sizes="180x180">GET /assets/favicon-html/evidence/format-probes/probe.png · 200 · image/png · one requestNot measured
SVG · 380 bytes · 180 × 180 viewBox<link rel="icon" href="/assets/favicon-html/evidence/format-probes/probe.svg" type="image/svg+xml" sizes="any">GET /assets/favicon-html/evidence/format-probes/probe.svg · 200 · image/svg+xml · one requestNot measured

Chrome's recorded request shows that this browser fetched the resource named by each test link and received the recorded type and status. It does not show that the favicon appeared in the tab: tab rendering was not measured. The SVG observation is limited to this Chrome run; other browsers and phones were not tested.

Download the raw Chrome request records and the fixture runner; its probes are the ICO file, PNG file, and SVG file.

For a summary of icon file, size, and display checks before choosing a specific fix, see the favicon overview.

Once your markup path is ready, create a favicon from the image you want to publish, then point the link at the deployed file.

Browser fixture: href resolution and response

A local Chrome fixture served four documents and a synthetic ICO. The page script fetched the URL resolved from each `link rel="icon"` element and recorded the final path, response, content type, and bytes.

Document URLHTML hrefResolved request pathHTTP statusResponse typeBytes
/root.html/favicon.ico/favicon.ico200image/x-icon36,827
/nested/root-link.html/favicon.ico/favicon.ico200image/x-icon36,827
/nested/relative.htmlfavicon.ico/nested/favicon.ico200image/x-icon36,827
/nested/missing.htmlmissing.ico/nested/missing.ico404text/plain9

One local Chrome 141.0.7390.98 run; no other browser or hosting provider was tested. The test calls fetch() on the resolved link URL to record the HTTP result; it does not measure favicon display or browser icon-cache behavior.

The favicon link setup sequence: publish the icon file, add the link inside the head, and request the resolved URL
The answer at a glance: Put the ICO at a known public URL · Add the link inside `<head>` · Request the resolved URL directly
Measured examples of root-relative and document-relative favicon paths resolving to different request locations
Browser fixture: href resolution and response: /root.html · /favicon.ico · /nested/root-link.html · /favicon.ico · /nested/relative.html · favicon.ico
Steps for installing and checking the favicon link in HTML
Install and check the link: Put the ICO at a known public URL · Add the link inside `<head>` · Request the resolved URL directly
Measured Windows icon requests: desktop shortcut and Chrome app small results are 16 × 16, large results are 32 × 32; browser tab, bookmark bar, and iPhone home-screen display sizes were not measured.
This Windows run returned 16 × 16 and 32 × 32. Browser tab, bookmark-bar, and iPhone display sizes were not measured.

FAQ

Favicon HTML questions

Where does the favicon link go in HTML?

Place the `link rel="icon"` element in the page's `<head>`, and set its href to the public URL of the ICO file.

Should I use `/favicon.ico` or `favicon.ico`?

Use `/favicon.ico` when the file is at the domain root. A relative `favicon.ico` resolves beside the current document, so nested pages may request a subfolder path.

What does a 404 on the favicon URL mean?

The server did not find a file at the requested path. Confirm the deployed file location and the resolved href before changing its image dimensions.

Does `rel="icon"` configure an iPhone Home Screen icon?

No. Apple's touch-icon route and a web-app manifest icon are separate from the page favicon link. This page covers the browser icon URL.

Will manually adding the image and code conflict with anything WordPress or the theme is doing?

It can create competing favicon declarations if WordPress or the active theme already outputs a Site Icon. Check the rendered page’s `<head>` before adding another tag; WordPress can emit several size-specific icon links by design, so compare each `href`, `type`, and `sizes` instead of deleting every extra line blindly. Prefer setting the icon through WordPress’s Site Icon control, then remove only a manually added declaration that points to the wrong file or conflicts with the intended result.