📜  favicon meta - Html (1)

📅  最后修改于: 2023-12-03 15:15:02.706000             🧑  作者: Mango

Favicon Meta - HTML

Favicon is the small icon that appears next to the website title in the browser tab. It helps in recognizing the website easily and quickly. The favicon can be customized based on the website's design and branding. In HTML, we can add the favicon using the <link> element with the rel attribute set to icon.

Adding Favicon Meta Tag

To add a favicon to your website, you need to create an image file with the .ico extension. Once you have the icon file, you can add the favicon meta tag to your HTML code. Here's how you can do it:

<link rel="icon" type="image/x-icon" href="favicon.ico">

The rel attribute is set to icon, which tells the browser that this is a favicon. The type attribute specifies the MIME type of the icon file, which is image/x-icon. Finally, the href attribute points to the location of the icon file.

Additional Favicon Meta Tags

Apart from the basic favicon meta tag, there are a few other meta tags that you can use to further customize the favicon:

Apple Touch Icon

The Apple Touch Icon is a special icon that appears on Apple devices when the user adds your website to their home screen. To add an Apple Touch Icon, use the following meta tag:

<link rel="apple-touch-icon" href="apple-touch-icon.png">

The href attribute points to the location of the icon file, which should be a square image with a size of at least 180x180 pixels.

Safari Pinned Tab Icon

The Safari Pinned Tab Icon is a special icon that appears when the user pins your website to their Safari tabs. To add a Safari Pinned Tab Icon, use the following meta tag:

<link rel="mask-icon" href="safari-pinned-tab.svg" color="#5bbad5">

The href attribute points to the location of the icon file, which should be an SVG image. The color attribute specifies the color of the icon when it is pinned.

Android Chrome Theme Color

The Android Chrome Theme Color is a special color that appears as the background color of the browser's UI when the user navigates to your website. To set the Android Chrome Theme Color, use the following meta tag:

<meta name="theme-color" content="#4285f4">

The content attribute specifies the color in hexadecimal format.

Conclusion

In HTML, the favicon can be added using the <link> element with the rel attribute set to icon. You can further customize the favicon using the Apple Touch Icon, Safari Pinned Tab Icon, and Android Chrome Theme Color meta tags.