Html 如何将我网站的徽标作为浏览器选项卡中的图标图像?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11488960/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 01:39:08  来源:igfitidea点击:

How do I put my website's logo to be the icon image in browser tabs?

htmlfavicon

提问by jay

The image next to the page title in the browser tab - how can you link an image here?

浏览器选项卡中页面标题旁边的图像 - 如何在此处链接图像?

回答by LasagnaAndroid

That image is called 'favicon'and it's a small square shaped .icofile, which is the standard file type for favicons. You could use .pngor .giftoo, but you should follow the standard for better compatibility.

该图像称为“网站图标,它是一个小型方形.ico文件,这是网站图标的标准文件类型。您可以使用.pngor .gif,但您应该遵循标准以获得更好的兼容性。

To set one for your website you should:

要为您的网站设置一个,您应该:

  1. Make a square image of your logo (preferably 32x32 or 16x16 pixels, as far as I know there's no max size*), and transform it into an .icofile. You can do this on Gimp, Photoshop (with help of a plugin) or a website like Favicon.ccor RealFaviconGenerator.

  2. Then, you have two ways of setting it up:

    A) Placing it on the root folder/directoryof your website (next to index.html) with the name favicon.ico.

    or

    B) Link to it between the <head></head>tags of every .htmlfile on your site, like this:

    <head>
      <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
    </head>
    
  1. 制作徽标的方形图像(最好是 32x32 或 16x16 像素,据我所知没有最大尺寸*),并将其转换为.ico文件。您可以在 Gimp、Photoshop(借助插件)或Favicon.ccRealFaviconGenerator等网站上执行此操作

  2. 然后,您有两种设置方式:

    A) 将其放置在您网站的根文件夹/目录中(在 旁边index.html),名称为favicon.ico

    或者

    B)在您网站上<head></head>每个.html文件的标签之间链接到它,如下所示:

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

If you want to see the faviconfrom any website, just write www.url.com/favicon.icoand you'll (probably) see it. Stackoverflow'sfavicon is 16x16 pixels and Wikipediais 32x32.

如果您想favicon从任何网站查看 ,只需写信www.url.com/favicon.ico,您(可能)就会看到它。Stackoverflow 的图标是 16x16 像素,维基百科是 32x32。

*: There's even a browser problem with no filesize limit. You could easily crash a browser with an exceedingly large favicon, more info here

*:甚至没有文件大小限制的浏览器问题。您可以轻松地使用超大图标使浏览器崩溃,更多信息请点击此处

回答by Dulith De Costa

It is called 'favicon' and you need to add below code to the headersection of your website.

它被称为“ favicon”,您需要将以下代码添加到您网站的标题部分。

Simply add this to the <head>section.

只需将其添加到该<head>部分即可。

<link rel="icon" href="/your_path_to_image/favicon.jpg">

回答by Vincent Ramdhanie

This is the faviconand is explained in the link.

这是图标,在链接中进行了解释。

e.g. from W3C

例如来自 W3C

  <link rel="icon" 
     type="image/png" 
     href="http://example.com/myicon.png">

Plus, of course the image file in the appropriate place.

另外,当然还有适当位置的图像文件。

回答by user3680001

<link rel="apple-touch-icon" sizes="114x114" href="${resource(dir: 'images', file: 
'apple-touch-icon-retina.png')}">

or you can use this one

或者你可以使用这个

<link rel="shortcut icon" sizes="114x114" href="${resource(dir: 'images', file: 'favicon.ico')}"
type="image/x-icon">

回答by Mike Fulton

Add a icon file named "favicon.ico" to the root of your website.

将名为“favicon.ico”的图标文件添加到您网站的根目录。