How to Add Favicon in HTML
Generate the correct HTML tags for your website icon. Upload an image to preview how it looks in a browser tab, then copy the standard code snippet.
🖼️ Upload Icon
Click to upload image
PNG, JPG, or SVG (Max 2MB)
Browser Tab Preview:
Quick Tip
For best results, place your favicon file in the root directory of your website (e.g., yourwebsite.com/favicon.ico) as some older browsers look there automatically.
What is a Favicon?
A favicon (short for “favorite icon”) is the small image you see in browser tabs next to the page title. It also appears in bookmark lists, history logs, and on mobile home screens when a user adds your site. Learning how to add a favicon in HTML is a small but crucial step in professional web development.
Supported File Formats
Historically, the .ico format was the only standard. Today, modern browsers support several formats:
- PNG (.png): The most common standard today. It supports transparency and high quality. Standard size is 32×32 or 16×16.
- SVG (.svg): The modern choice. Scalable Vector Graphics look crisp on any resolution and support dark mode styling via CSS.
- ICO (.ico): The legacy format. Still useful as a fallback for very old browsers (like IE).
- Apple Touch Icon: iOS devices don’t use the standard favicon. They look for a specifically named
apple-touch-icon.png(usually 180×180 pixels).
Step-by-Step Implementation in HTML
1. Create your icon: Design a square image. Ideally, export it as a 32×32 PNG for the browser and a 180×180 PNG for mobile.
2. Upload the file: Place the image file in your website’s folder (e.g., inside an images folder or at the root).
3. Add the HTML: Paste the code generated above inside the <head> section of your HTML document.
Adding Favicon in WordPress
If you are using WordPress, you often don’t need to edit HTML code directly. You have two primary options:
Method 1: The Native “Site Icon” (Recommended)
WordPress has a built-in feature for this. It handles the HTML generation for you automatically.
- Log in to your WordPress Dashboard.
- Go to Appearance > Customize.
- Click on Site Identity.
- Look for the Site Icon section and click “Select Site Icon”.
- Upload an image (WordPress recommends 512×512 pixels).
- Click “Publish”. WordPress will automatically crop it and add the necessary code for all devices.
Method 2: Using Plugins
If your theme doesn’t support Site Icons, or you need specific control over different platforms (like a specific tile color for Windows 10), you can use a plugin.
- RealFaviconGenerator: A robust plugin that lets you configure specific icons for iOS, Android, Windows, and macOS Safari. It ensures your icon looks perfect everywhere.
- All In One Favicon: A simpler alternative that allows you to upload separate .ico, .png, and .gif icons for the frontend and admin area.
Example Code Breakdown
The code <link rel="icon" type="image/png" href="..."> tells the browser two things:
rel="icon": This link is for the website icon.href="...": Where the image file is located.
By including both the standard icon link and the Apple Touch Icon link (as generated by the tool above), you ensure your site looks great on Desktops, Androids, and iPhones.
https://quickcalculators.in/how-to-add-google-analytics-4-to-website/