1

I have this horrible problem with favicon.ico in my HTML page. Here's a look at my code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<title>Games</title>

I have put the favicon in the same directory as my HTML file because putting it in my resources folder didn't seem to work either. What do I do? It will not show up ANYWHERE on ANY browser.

4

3 回答 3

1

You need to put it in the root web directory. Why? Because that's what you're linking to.

于 2013-08-28T17:24:20.243 回答
1

使用替代语法:

 <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
于 2013-08-28T17:25:59.857 回答
0

如果您只想测试网站图标是否在本地工作,请将路径更改为favicon.ico文件相对于 HTML 文档的位置:

如果它位于名为的子目录中foo

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

如果是上一级目录:

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

等等

于 2013-09-20T21:16:47.607 回答