HTML 标题图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3103490/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTML Title Image
提问by James
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?
我想在 HTML 页面的标题上有一个图像(即与标题一起在选项卡上)。我怎样才能做到这一点?
回答by Ed B
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
您需要的是 favicon.ico 文件。只需将它放在您网站的根目录中,并在您的页面标题中链接到它
<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.
你应该把它放在你网站的根目录中,并将它命名为 favicon.ico 因为即使你没有在你的页面上链接到它,一些浏览器也会寻找它。
回答by Zuul
For cross browser compatibility, seems to be needed two lines for for favicon:
对于跨浏览器兼容性,对于 favicon 似乎需要两行:
TITLE
标题
<title>PAGE TITLE HERE</title>
FAVICON
图标
<link rel="SHORTCUT ICON" href="http://domain and path/favicon.ico" />
<link rel="icon" href="http://domain and path/favicon.ico" type="image/ico" />
FAVICON GENERATOR:
图标生成器:
回答by Hendrik Brummermann
Please add a line similar to this within the head-elements:
请在 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.
.ico 文件在旧浏览器中效果最好,但当然您也可以使用 png 和 jpeg 文件。
回答by JD Courtoy
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.
将此标记添加到您的<head />
,它将指示站点的浏览器下载 href 中引用的图像。
回答by T.T.T.
How to Add a Favicon to your Site (W3C):
http://www.w3.org/2005/10/howto-favicon
如何将 Favicon 添加到您的站点 (W3C):http:
//www.w3.org/2005/10/howto-favicon
and you can make any image a favicon with online generators like these:
http://tools.dynamicdrive.com/favicon/
您可以使用以下在线生成器将任何图像制作为图标:http:
//tools.dynamicdrive.com/favicon/
回答by stardust4891
You can also use a png
image and make it a minimum of 310x310px to support all known devices. A modern browser will automatically size it accordingly.
您还可以使用png
图像并使其最小为 310x310 像素以支持所有已知设备。现代浏览器会相应地自动调整大小。
回答by MineForge
i just found the icon i wanted online, right click and select "copy image URL"
我刚刚在网上找到了我想要的图标,右键单击并选择“复制图像 URL”
<head>
<title>(title)</title>
<link rel="shortcut icon" href="(image URL)"/>
<head>