将一个favicon添加到静态HTML页面 [英] Adding a favicon to a static HTML page

查看:95
本文介绍了将一个favicon添加到静态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 pic 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.

推荐答案

您可以制作16x16 .png然后在静态HTML文档的< head> 标记之间使用以下代码片段之一:

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

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

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

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