现在的位置: 首页 > 综合 > 正文

使用link标签实现shortcut icon

2018年04月16日 ⁄ 综合 ⁄ 共 674字 ⁄ 字号 评论关闭

在HTML中可以使用link标签来实现shortcut icon。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/dtd/xhtml1-transitional.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>link标签实现shortcut</title>
		<link rel="shortcut icon" type="images/x-icon" href="http://www.baidu.com/favicon.ico">
	</head>
	<body>
		Hello, please look at the shortcur icon.
	</body>
</html>

把href换成自己网站的favicon即可。


参考:http://zh.wikipedia.org/wiki/Favicon


这里的favicon必须是16*16或者32*32的,必须是8位色或者24位色的,格式必须是png或者ico或者gif。

16*16/32*32 且 8位或24位色 且 png/ico/gif。


另一种实现favicon的方法是把名为favicon.ico的图片放在WEB根目录下。这种方法不推荐,因为这种方法违反了互联网规范,这个图片的访问是没有被授权的。


参考:http://www.w3.org/2005/10/howto-favicon


抱歉!评论已关闭.