A few things about favicon.ico (it’s best to put it in the root directory)

A few things about favicon.ico (it’s best to put it in the root directory)

Open any web page: for example, http://www.baidu.com/

image

You can see that there is an icon displayed on the browser tab header. This icon is: image , which is what we often call favicon.ico.

Since this article mainly discusses favicon.ico and the different ways in which each browser handles it, we will create a new web project as follows:

image

image

image

image

The code of home.html is as follows:
XML/HTML CodeCopy content to clipboard
  1. <!DOCTYPE html >   
  2. < html   xmlns = "http://www.w3.org/1999/xhtml" >   
  3. < head >   
  4.      < title > home page </ title >   
  5.      < link   rel = "icon"   href = "Images/wangyi.ico"   type = "image/x-icon"   />   
  6.      < link   rel = "shortcut icon"   href = "Images/wangyi.ico"   type = "image/x-icon"   />   
  7. </ head >   
  8. < body >   
  9. home page
  10. </ body >   
  11. </ html >   

firefox: image

ie9: image

Unfortunately, most ordinary users use 360 ​​browser, Sogou browser, QQ browser, etc.

Sogou Browser: image

It can be seen that the favicon.ico in the root directory of the website is effective, so the favicon.ico icon in the root directory of the website is displayed.

Open 360 Browser: image

Strange, where did the Google icon come from? . . . ? ? ?

Our faviconTestWeb has only 3 icons, one of which is wangyi.ico.baidu.ico.favicon.ico (the icon of cnblogs).

Why does 360 display the Google icon?

In fact, when 360 browser browses the web, it will ignore the port, that is, http://localhost:3529/home.html,

Firefox requests the icon corresponding to the href of the link.

Sogou Browser, etc.: The request is http://localhost:3529/favicon.ico.

360 browser, etc.: The request is http://localhost/favicon.ico,

That is, no matter whether you request http://host/home.html, http://host:333/home.html, or http://host/test/home.html.

It requests http://host/favicon.ico.

The evidence is to open the 360se installation directory:

image

So if your website's favicon.ico doesn't work, or if you want to make favicon.ico more compatible, use the following steps:

1: Check the favicon.ico in the root directory of the website, that is, http://host/favicon.ico., not http://host/some/favicon.ico.

2: Make sure <link rel="icon" href="http://host/favicon.ico" type="image/x-icon" />

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

Using http://host/favicon.ico

3: If your website has a port, or is a test version, then pay special attention to browsers such as 360, which will ignore the port number when requesting favicon.ico.

<<:  Detailed explanation of the process of installing MySQL on Ubuntu 18.04.4

>>:  MySQL database terminal - common operation command codes

Recommend

How to disable IE10's password clear text display and quick clear function

IE10 provides a quick clear button (X icon) and a ...

Using HTML+CSS to track mouse movement

As users become more privacy-conscious and take m...

Docker enables multiple port mapping commands

as follows: docker run -d -p 5000:23 -p 5001:22 -...

Nginx load balancing algorithm and failover analysis

Overview Nginx load balancing provides upstream s...

Summary of Css methods for clearing floats

Float is often used in web page layout, but the f...

Linux command line operation Baidu cloud upload and download files

Table of contents 0. Background 1. Installation 2...

How to define data examples in Vue

Preface In the development process, defining vari...

JavaScript event delegation principle

Table of contents 1. What is event delegation? 2....

Examples and comparison of 3 methods for deduplication of JS object arrays

Table of contents 1. Comparison of data before an...

Example of how to install kong gateway in docker

1. Create a Docker network docker network create ...

HTML tag marquee realizes various scrolling effects (without JS control)

The automatic scrolling effect of the page can be...

Practice of using SuperMap in Vue

Table of contents Preface Related Materials Vue p...

MySQL series 15 MySQL common configuration and performance stress test

1. Common MySQL configuration All the following c...