Export (0) Print
Expand All

How to Add a Shortcut Icon to a Web Page

Note  If you are looking for help creating desktop shortcuts, please see Add icons to the desktop or taskbar. This article describes how to create favorite icons for earlier versions of Internet Explorer. For more recent information, see the Customizing the Site Icon article.

You can use shortcut icons to display your logo or some other small graphic on the Windows Internet Explorer Favorites menu, address bar, and—starting with Windows Internet Explorer 7—page tabs. They have no special Web server requirements and are a great way to add brand recognition to your Web site. The following screen shot shows a shortcut icon for MSN.com on the Favorites menu, the address bar, and a page tab.

Shortcut icon in several locations on the screen

Until Internet Explorer 7, shortcut icons would appear only when users added a page to their Favorites. Starting with Internet Explorer 7, shortcut icons will always appear when one is available in a supported format.

This article describes how Internet Explorer handles shortcut icons, explains how to add shortcut icons to your Web page, and provides troubleshooting steps. This article contains the following sections:

About Shortcut Icons

Shortcut icons are supported in Microsoft Internet Explorer 5 and later. Internet Explorer downloads a shortcut icon when a user first visits a Web page that has a valid icon. (For more information on what constitutes a valid shortcut icon, see Creating Icons in the Correct Size and Format.) If more than one Web page shares the same shortcut icon (for example, a Web site that uses the same shortcut icon site-wide), the shortcut icon is downloaded only once.

In Internet Explorer 7, when a user adds a site to the Favorites menu, the site's shortcut icon is saved to the Microsoft Windows NT File System (NTFS) alternate data stream of the shortcut (.url) file that is created. (On hard disks formatted with the file allocation table (FAT) file system, the icon is saved to the Temporary Internet Files folder.)

In Microsoft Internet Explorer 6, the icon is stored in the Temporary Internet Files folder on the user's computer, and additional metadata about the icon is stored in the user's history information.

Creating Icons in the Correct Size and Format

A shortcut icon for Internet Explorer must be square in size, and at least 16 x 16 pixels. Consider creating both a 16 x 16-pixel icon as well as a 32 x 32-pixel icon (and larger, bandwidth permitting), since on high-DPI displays, Internet Explorer may stretch the icon to fit the available space.

To create the icon, use an icon editor, such as Microsoft Paint or the one included in Microsoft Visual Studio, and save the icon in the .ico file format (or save as a bitmap, and then rename the file with a ".ico" extension). Internet Explorer will ignore icons that are not in .ico format, and will instead display the default Internet Explorer shortcut icon.

Associating the Shortcut Icon with Your Web Page

After creating the icon, you must associate it with your Web page. There are two methods for doing this.

The first method is to save the icon with the default file name of favicon.ico to the root directory of your domain—for example, www.microsoft.com/favicon.ico. The first time a user visits your Web page, Internet Explorer automatically searches for this file and places the icon in the address bar, next to all favorites linking to your site, and on page tabs. In Internet Explorer 5 and Internet Explorer 6, the icon will appears only after a user adds the site to the Favorites menu.

The second method for associating a shortcut icon with your Web page is to add a line of HTML code to the page's head element. The line of code includes a link tag that specifies the location and name of the icon file. You can include this link tag on a per-page basis. First, save the icon with a file name other than favicon.ico, and then add the following code to the head element of your page.


<head>
  <link rel="SHORTCUT ICON" href="http://www.mydomain.com/myicon.ico"/>
  <title>My Title</title>
</head>

You can use either method, or both. However, if you use the second method, whichever icon you point to in the link tag on each page will be displayed instead of the default favicon.ico file at the root of your domain.

Associating Multiple Shortcut Icons with Different Web Pages

If you want different pages on your Web site to have different shortcut icons, you must use a link tag as described in Associating the Shortcut Icon with Your Web Page. Within the link tag, point to whichever shortcut icon you want to display for that page.

Changing Your Page's Shortcut Icon

If you have used only the default favicon.ico file at the root of your domain as your shortcut icon, and you change the icon, your users may not see the updated icon until they have cleared their history and cache as described in Troubleshooting Shortcut Icons. Internet Explorer cannot detect whether favicon.ico has changed, so it will load a new copy only if it does not have one already.

To prevent this, use a link tag as described in Associating the Shortcut Icon with Your Web Page and use a different file name for the new shortcut icon. Internet Explorer compares the file name in the link tag to the known file name stored in the history information. If the file name has changed, Internet Explorer downloads the new icon.

Adding the Web Page to the User's Favorites Menu

In Internet Explorer 5 and Internet Explorer 6, a shortcut icon does not appear on the address bar unless the user chooses to add the page as a favorite. You can add a button or link to your page that prompts the user to add your page as a favorite. The following code is an example of one way to do this.


<script>
<!--
if ((navigator.appVersion.indexOf("MSIE") > 0)
  && (parseInt(navigator.appVersion) >= 4)) {
    var sText = "<u><span style='color:blue;cursor:hand;'";
    sText += "onclick='window.external.AddFavorite(location.href,";
    sText += "document.title);'>Add this page to your favorites</span></u>";
    document.write(sText);
}
//-->
</script>

Troubleshooting Shortcut Icons

If you are seeing the incorrect or default shortcut icon for your Web page, try the following:

  • Verify that the shortcut icon is the correct size and format. For more information, see Creating Icons in the Correct Size and Format. Note that shortcut icons in image formats other than .ico—for instance, .bmp, .gif, or .png—cannot be displayed in Internet Explorer.
  • Clear the Internet Explorer cache and history information. If either has become corrupted, incorrect shortcut icons may appear.
    • To clear the cache and history information in Internet Explorer 7, on the Tools menu, click Delete Browsing History. Click Delete files to clear the cache, and click Delete history to clear the history information. Also, since shortcut icons for favorites are stored in the shortcut (.url) file in Internet Explorer 7, try removing the favorite and adding it again.
    • To clear the cache and history information in Internet Explorer 6, on the Tools menu, click Internet Options. Under Temporary Internet files, click Delete files, and under History, click Clear history.
  • Verify that Internet Explorer can store the shortcut icon in the Temporary Internet Files folder. If you have set Internet Explorer to not keep a cache, then it will not be able to store the icon and will display the default Internet Explorer shortcut icon instead.

 

 

Show:
© 2014 Microsoft