向静态 HTML 页面添加收藏夹图标 [英] Adding a favicon to a static HTML page

查看:42
本文介绍了向静态 HTML 页面添加收藏夹图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些纯 HTML 的静态页面,我们会在服务器出现故障时显示这些页面.我怎样才能将我制作的图标(它是 16x16px,它与 HTML 文件位于同一目录中;它被称为 favicon.ico)作为标签"图标?我已经阅读了维基百科并查看了一些教程并实现了以下内容:

I have a few static pages that are just pure HTML, that we display when the server goes down. How can I put a favicon that I made (it's 16x16px and it's sitting in the same directory as the HTML file; it's called favicon.ico) as the "tab" icon as it were? I have read up on Wikipedia and looked at a few tutorials and have implemented the following:

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

但它仍然不想工作.我正在使用 Chrome 来测试网站.根据维基百科,.ico 是在所有浏览器类型上运行的最佳图片格式.

But it still doesn't want to work. I am using Chrome to test the sites. According to Wikipedia .ico is the best picture format that runs on all browser types.

我无法让它在本地工作,尽管代码检查出来它只有在服务器开始为站点提供服务后才能真正正常工作.只需尝试将其推送到服务器并刷新缓存,它应该可以正常工作.

I could not get this to work locally although the code checks out it will only really work properly once the server started serving the site. Just try pushing it up to the server and refresh your cache and it should work fine.

推荐答案

您可以制作一个 .png 图像,然后在静态 HTML 的 <head> 标记之间使用以下片段之一文件:

You can make a .png image and then use one of the following snippets between the <head> tags of your static HTML documents:

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

这篇关于向静态 HTML 页面添加收藏夹图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆