Search code examples
phphtmlfavicon

Setting up the favicon


I have following code for my header.php file, in the includes folder.

<html>
    <head>
        <title>Health Mate</title>
        <link rel="icon" href="/favicon.ico" type="image/x-icon" />
        <link href="stylesheets/public.css" media="all" rel="stylesheet"/>
     </head>
     <!-- Some more code-->
 </html>

I have pasted favicon.ico in the includes folder itself.Problem is the favicon is not setting up.Also If i redirect user to some site on submit button like yahoo.com . My site is taking favicon of yahoo. Please suggest some solution. Also tell me if favicon needs to be .ico file or it can be .png as well?


Solution

  • You should have necessary path needed to locate your favicon.ico image.

    Eg: If your folder is structured this way:

    /mysite
      /includes
         favicon.ico
      index.php
    

    If you're going to use it in index.php you should include the necessary path needed like this:

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

    Note: for checking if your like get the path towards your icon image.. you could check your web page source code using ctrl + u. Then click the href path linked if it displays the image it means your path is correct.