51

I want to have an image on the title in an HTML page (i.e on the tab along with the title). How can I do that?

4

4 回答 4

54

What you need is a favicon.ico file. Just put it in the root of your site and link to it in the header of your page

<head>
    <title>My Site</title>
    <link rel="shortcut icon" href="favicon.ico" />
</head>

You should put it in the root of your site and name it favicon.ico because some browsers look for it even if you don't link to it on your pages.

于 2010-06-23T16:24:03.003 回答
24

对于跨浏览器兼容性,似乎需要两行用于 favicon:

标题

<title>PAGE TITLE HERE</title>

网站图标

<link rel="SHORTCUT ICON" href="http://domain and path/favicon.ico" />
<link rel="icon" href="http://domain and path/favicon.ico" type="image/ico" />

网站图标生成器:

动态驱动

于 2010-06-23T17:48:52.520 回答
5

Please add a line similar to this within the head-elements:

<link rel="shortcut icon" href="/somwhere/icon.ico">

.ico files work best among old browser, but of course you can use png and jpeg files, too.

于 2010-06-23T16:24:03.273 回答
4

You are wanting to set a favicon. Here is the tag to do that:

<link rel="SHORTCUT ICON" href="favicon.ico" />

Add this tag to your <head /> and it will instruct browsers of the site to download the image referenced in the href.

于 2010-06-23T16:24:32.663 回答