Displaying Favicon in ASP.NET Page

A favicon is the little image displayed at the left edge of the address bar in most browsers, or on the tab. Adding a Favicon is a nice way to enhance your website and give it a finished look.

Firefox displaying favicon:

Google Chrome displaying favicon:


Interner Explorer displaying favicon:

Adding a favicon to your website is very easy. First you need to create a 16 by 16 pixel icon and name it favicon.ico. No other file format or size will do. Save your favicon to the root directory of your ASP.Net web application:


In some older browsers (e.g., Internet Explorer 5), that's all it takes. For the latest versions of Firefox, Internet Explorer and Chrome, however, you need to add two links to your favicon to the head in your HTML. If you are using a master page, the same two links would go in the head on the master page.:

                <head runat="server">
                <
title>My Website</title>
                <
link runat="server" rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
                <
link runat="server" rel="icon" href="favicon.ico" type="image/ico"/>
          </
head>


The reason you have two links to the same favicon is to make sure your favicon works with most browsers. Some, such as Firefox, will work with either link. Internet Explorer versions 6 and 7 are especially picky. If you use both links, however, one is bound to work in almost any browser.

Ebook Download
View all
Learn
View all