Browser addressbar icon (favicon)

Hi, all of you must have noticed that when you visit a website with your browser, the image on the left of the addressbar changes. First of all lets define its correct term. It is known as the 'favIcon'.

In this post, I wish to demonstrate how to add such a favicon to your website. To try this out, you would need a web server such as IIS, Apache or Tomcat. I'm using WAMP's Apache server for the demonstration.

First of all, you'll need an image of dimension 16x16. You can use windows paint to do this. Save it in Windows 16 colors. If you need to do this quickly, you can use the following website, which will generate a favicon from a given image.
Save the image as favicon.ico. Now, copy and paste this on your web server root directory of the application.

The folder structure of WAMP is based in a way such that the web applications need to be deployed in the folder named "www". (The complete path for this is "C:\wamp\www") Now, create a separate folder for your application inside the root folder.




For the demonstration, I will use a simple web site with just one web page. It would display the simple Hello World message. Just copy the following code segment into a text editor and save it as "index.html". Now, place this html code in your web server's application root folder.

<html>
<head>
<link rel="shortcut icon" href="favicon.ico">
</head>

<body>
<table>
<tr>
<td>Hello World!</td>
</tr>
</table>
</body>
</html>

Now, make sure that you place the code in red in the header. It is needed if you need to change the image location other than the root folder. So, if you need to save the image in a folder named images, then you could simply locate the file using the path to the directory.

Now, the folder structure should be similar to the following.



Now, start your web server. In my case, I would start WAMP's Apache service. Then view it through a browser. When you view it, it should be automatically displayed on the left of the addressbar.



NOTE: You may sometimes need to clear the browser cash for the image to be displayed and restart the Web Server.

Cheers

Comments

Popular posts from this blog

Encrypt and Decrypt Images Using Java

Build your own Network sniffer

ASP Response.Write newline