This is because the browser itself tries to search for the image favicon.ico
in the root folder of your site or localhost. This usually occurs in Safari and Chrome (in other browsers I didn’t notice this behavior), so when does not define the:
<link rel="shortcut icon" href="...."/>
The browser alone will try to find the http://localhost/favicon.ico
or http://site.com/favicon.ico
What you can do is put your favicon in the Wamp root folder and clear the browser cache, or you can simply create a include via PHP and add to all pages:
header.php:
<link rel="shortcut icon" href="...caminho do favicon..."/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
And on all pages add:
<head>
<title>Meu titulo</title>
<?php include 'header.php'; ?>
</head>
Relative vs absolute paths
The relative path is the one that loads relative to the path of the current page, so if it is on the page
http://localhost/pagina.php
It will look for the favicon in:
http://localhost/img/favicon.ico
if you’re on the page
http://localhost/foo/bar/baz/pagina.php
It will look for the favicon in:
http://localhost/foo/bar/baz/img/favicon.ico
That is to say it is the wrong way, so to avoid this add the complete (absolute) path of the favicon, for example:
header.php:
<link rel="shortcut icon" href="http://localhost/img/favicon.ico"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
However if you are going to send to a server, this will not work then you will have to change the address, in case you can use only the absolute path, without HTTP, putting a bar in front so /img/favicon.ico
, this way it will search from root, example:
<link rel="shortcut icon" href="/img/favicon.ico"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Guy Favicon usually stays at Cash, tries to clear the cash to see if it resolves
– hugocsl
already cleaned. I deleted browser history by selecting all options
– ARodrigues
Since you are declaring the file as . ico try declaring his Type in the tag. Thus: <link rel="shortcut icon" TYPE="image/x-icon" href="img/favicon.ico" /> sometimes resolves...
– hugocsl
Friend without the favicon link becomes difficult.... Because you don’t put the image of
<head>
already with the link of the right favicon?– hugocsl
It was posted for the conference.
– ARodrigues
there is something wrong in the second image not as it says with the first, the header has only 2 css already in your html has 3 css, 2 script, icon...
– HudsonPH
The second image is a print of CTRL+U in the browser. That’s why javascript doesn’t look normal. But the icon should appear. If it is not showing up, it is because the browser is not recognizing the code. And this is my problem
– ARodrigues