How to add a small icon to the page title

What I will share with you today is how to add a small icon to the page title, just like the red C in front of CSDN.

There are mainly two methods:

1. Add the following code in the head section of the html file (note the path of href).

<link rel="icon" type="image/x-icon" href="icon.ico" />
The format of your icon is preferably .ico format. I tried it out and found that both png and jpg formats can be used, and the browser will automatically scale the image size to 16*16 for you. However, the .ico format is much smaller, and pay attention to the issue of transparency. Pictures in jpg and bmp formats will lose their transparency, so it is recommended to transfer them.
If you don't want to download a picture format conversion tool or an icon icon maker, here is an online conversion address .

2. Make an icon in ico format. For compatibility reasons, the color used should not exceed 16 colors. The naming requirement of this icon here must be favicon.ico. Just put this icon in the root directory of the website. When the page loads, the browser will automatically retrieve this icon and add it to the title.

I'm Shire , click on the name to visit my personal website , and I will share more solutions to practical development problems in the future.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325390561&siteId=291194637