close
The Wayback Machine - https://web.archive.org/web/20250414082136/https://www.geeksforgeeks.org/html-favicon/
Open In App

HTML Favicon

Last Updated : 19 Dec, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

An HTML favicon (or favorite icon) is a small image or icon that represents a website, typically shown in the browser tab, bookmarks, and shortcuts. It is used for:

  • Brand Recognition: Favicons are a visual marker for your brand online, helping to increase and reinforce brand awareness.
  • Professionalism: A well-designed favicon makes your site look professional and credible.
  • Usability: It improves the user’s navigation experience by allowing them to easily identify and switch to your tab when multiple tabs are open.

How to Implement a Favicon in HTML

To add a favicon to your HTML document, you’ll need to reference it in the <head> section of your HTML code. Here’s how you can do it:

HTML
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>HTML Favicon</title>

    <!-- Add icon link -->
    <link rel="icon" href="https://media.geeksforgeeks.org/wp-content/cdn-uploads/gfg_200X200.png" type="image/x-icon">
</head>

<body>
    <h3 style="color:green;">
        GeeksforGeeks
    </h3>
    <p>Welcome to my website</p>
</body>

</html>

Output:

favicon

In this example:

  • rel=”icon”: Indicates that the linked resource is an icon for the document. This relationship is essential for browsers to understand that the specified file is meant to be used as the website’s favicon.
  • href=”https://media.geeksforgeeks.org/wp-content/cdn-uploads/gfg_200X200.png”: Specifies the path to the favicon image. This can be a URL (as used here) pointing to an image that serves as the icon.
  • type=”image/x-icon”: Specifies the MIME type of the favicon file. While commonly image/x-icon is used for .ico files, modern browsers support PNG and other formats as well.

Note: Major browsers are not supported by the sizing property of the favicon.

List of Favicon Sizes

Different devices and browsers may require favicons of various sizes. Here’s a list of common favicon sizes:

Name

Size

Description

favicon-32.png

32×32

Standard for most desktop browsers.

favicon-57.png

57×57

Standard iOS home screen.

favicon-76.png

76×76

iPad home screen icon.

favicon-96.png

96×96

GoogleTV icon.

favicon-120.png

120×120

iPhone retina touch icon.

favicon-128.png

128×128

Chrome Web Store icon & Small Windows 8 Star Screen Icon*.

favicon-144.png

144×144

Internet Explorer 10 Metro tile for pinned site*

favicon-152.png

152×152

iPad touch icon.

favicon-167.png

167×167

iPad Retina touch icon (change for iOS 10: up from 152×152, not in action. iOS 10 will use 152×152)

favicon-180.png

180×180

iPhone 6 plus

favicon-192.png

192×192

Google Developer Web App Manifest Recommendation

favicon-195.png

195×195

Opera Speed Dial icon

(Not working in Opera 15 and later)

favicon-196.png

196×196

Chrome for Android home screen icon

favicon-228.png

228×228

Opera Coast icon

Favicon File Format Support

Here’s a table summarizing the common file formats supported for favicons:

File FormatBrowser SupportAdvantagesDisadvantages
ICO
  • Edge
  • Chrome
  • Firefox
  • Opera
  • Safari
Supports multiple sizes in a single file; widely supportedLarger file size compared to others
PNG All FiveHigh-quality image, supports transparency, smaller file sizeDoes not support multiple sizes in one file
GIFAll FiveSupports animationLimited color palette (256 colors), less ideal for favicons
JPEGAll FiveGood for high-quality imagesDoes not support transparency, larger file size
SVGAll FiveScalable, small file size, sharp quality at any resolutionNot supported by all browsers (especially older ones)
WebPAll FiveSmaller file size with high qualityLimited browser support, not widely used for favicons


Next Article

Similar Reads