How to Add a Favicon in HTML (With Code Examples)
Learn how to add a favicon to your HTML website using simple code. Includes ICO, PNG, Apple touch icon examples, and common troubleshooting tips.

In this post
- How to Add a Favicon in HTML (With Code Examples)
- Step 1: Create a Favicon for Your Website
- Step 2: Upload the Favicon to Your Website
- Step 3: Add the Favicon HTML Code
- Step 4: Use the Correct File Path
- Can You Use a PNG as an HTML Favicon?
- How to Add an Apple Touch Icon
- Do You Need a Web App Manifest?
- Why Isn't My Favicon Showing After Adding the HTML?
- What Favicon Size Should You Use?
- Does Adding a Favicon Help SEO?
- One Last Check Before You're Done
How to Add a Favicon in HTML (With Code Examples)
You've built a website, added your logo, and everything looks good.
But there's still one little detail missing: the icon in the browser tab.
That's your favicon.
Adding a favicon to an HTML website is simple. You just need an image file and a link tag inside the head section of your page.
Here's the basic code:
<link rel="icon" href="/favicon.ico">That tells the browser where to find your favicon.
Let's go through how to create the file, add it to your website, and fix the common problems that can come up.
Step 1: Create a Favicon for Your Website
Before adding the HTML code, you'll need an actual favicon image.
You can use a JPG, PNG, or another supported image as your starting point.
For example, if you've already got a company logo, there's no need to design a completely new graphic.
Open JPGtoIcon, upload your logo, and select the Favicon preset.
You can adjust cropping, shape, padding, and background settings.
Then download the ICO file.
The favicon.ico file can contain several icon sizes, such as 16×16, 32×32, and 48×48 pixels.
If you want additional device icons, the Favicon Pack option provides PNG icons, a web app manifest, and example HTML code.
Step 2: Upload the Favicon to Your Website
Once you've downloaded favicon.ico, upload it to your website.
For a simple static HTML site, you might place it in the same public directory as your index.html file.
Your project could look like this:
website/
index.html
favicon.ico
styles.cssIf that directory is published as your website's root, the favicon should be accessible at:
https://example.com/favicon.ico
Try opening the file URL in your browser.
If it doesn't load, check the upload location and file path before continuing.
Step 3: Add the Favicon HTML Code
Open your HTML file.
Find the head section, which usually appears near the top of the page.
Add the favicon link like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Website</title>
<link rel="icon" href="/favicon.ico">
</head>
<body>
<h1>Welcome to my website</h1>
</body>
</html>Save the file and upload the updated page if necessary.
The leading slash in /favicon.ico means the URL starts at the root of your website.
If your favicon is stored somewhere else, you'll need a different path.
Step 4: Use the Correct File Path
Let's say your favicon is stored in an images directory instead of the root.
Your website might look like this:
website/
index.html
images/
favicon.icoIn that case, use:
<link rel="icon" href="/images/favicon.ico">A common mistake is putting the favicon in one folder while the HTML points to another.
If your favicon isn't showing, always check the actual URL first.
Can You Use a PNG as an HTML Favicon?
Yes. Modern browsers support PNG favicons.
For example:
<link rel="icon" type="image/png" sizes="32x32"
href="/favicon-32x32.png">You can also include multiple icon links:
<link rel="icon" href="/favicon.ico">
<link rel="icon" type="image/png" sizes="32x32"
href="/favicon-32x32.png">Browsers consider the supplied icon information when choosing a suitable file.
For a small, straightforward website, a single multi-size favicon.ico may be sufficient.
For a more complete setup, additional PNG icons can be useful.
How to Add an Apple Touch Icon
Apple touch icons are used for website icons in certain Apple home-screen experiences.
A common size is 180×180 pixels.
Add the following line inside the head section:
<link rel="apple-touch-icon"
href="/apple-touch-icon.png">Make sure the file actually exists at that location.
Unlike a traditional favicon.ico, an Apple touch icon is normally provided as a PNG.
If you're using JPGtoIcon's Favicon Pack, the Apple touch icon is included.
Do You Need a Web App Manifest?
Not every website needs one.
A web app manifest is useful if your website supports progressive web app features, including installation on supported devices.
It can describe your application's name, icons, colors, and other details.
To reference a manifest in HTML, use:
<link rel="manifest" href="/site.webmanifest">The manifest file needs to contain the appropriate configuration, and the icon files it references must be available.
JPGtoIcon's favicon pack includes a manifest and associated icon files, which can help with initial setup.
Keep in mind that adding a manifest alone doesn't automatically turn a website into a fully installable app.
Why Isn't My Favicon Showing After Adding the HTML?
If you've added the code but can't see the icon, don't immediately assume the HTML is wrong.
Here are a few things to check.
The File Path Is Incorrect
Open the favicon URL directly in your browser.
If you get a 404 error, fix the path or upload the file to the correct location.
The Browser Is Displaying an Old Icon
Browsers can cache favicons.
Try opening the website in a private window or another browser.
If your website uses a CDN, make sure the updated icon file is actually being served.
The File Format Is Invalid
Don't rename a JPG or PNG to favicon.ico and expect it to work.
An ICO file has its own internal structure.
Use a proper converter to generate the file.
Your Website Has Multiple Favicon References
Some themes, frameworks, and website builders add their own favicon links.
Check the generated HTML to see whether several links are pointing to different icons.
Remove outdated references when appropriate.
What Favicon Size Should You Use?
For a traditional ICO favicon, common sizes include 16×16, 32×32, and 48×48 pixels.
For other device uses, you may need larger PNG icons.
| File | Typical dimensions |
|---|---|
| favicon.ico | 16, 32 and 48 px |
| favicon-32x32.png | 32×32 |
| apple-touch-icon.png | 180×180 |
| android-chrome-192x192.png | 192×192 |
| android-chrome-512x512.png | 512×512 |
These are common file names and sizes, not mandatory names for every project.
What's important is that your HTML and manifest reference the correct files.
Does Adding a Favicon Help SEO?
A favicon isn't a substitute for good website content or technical SEO.
However, it helps people recognize your website in browser tabs, bookmarks, and potentially Google Search results.
Google can display a website's favicon in organic search results when the file meets its requirements and is accessible to crawlers.
Google recommends using a square, clearly recognizable icon larger than 48×48 pixels.
For exact requirements, check Google's favicon guidelines.
One Last Check Before You're Done
Once you've uploaded your favicon and added the HTML link, check the website in more than one browser.
Make sure the icon is recognizable at a small size, the file loads correctly, and the HTML points to the right location.
You can also test the website on a mobile device.
If you haven't created your favicon yet, JPGtoIcon's free favicon generator can turn an existing image into an ICO file or a complete favicon pack.
For a basic website, one small HTML tag might be all you need. The rest is making sure the image itself is ready to use.
Frequently asked questions
How do I add a favicon in HTML?
Upload a favicon file to your website and place a link element such as inside the head section of your HTML document.
Where should favicon.ico be placed?
You can place favicon.ico in the website root or another public directory. Make sure the HTML href points to the correct file path.
Can I use PNG for a favicon in HTML?
Yes. Modern browsers support PNG favicons. Use a link element with rel="icon", type="image/png", and the correct image URL.
Why is my HTML favicon not showing?
Common causes include incorrect file paths, missing image files, browser caching, invalid image formats, or conflicting favicon links.
Comments