HTML Tutorial - HTML Favicon








The link element can define an icon associated with your page. Different browsers handle the icon in different ways, but typically the icon appears on a page tab, and when the user adds your page to the favorites list.

A Favicon icon is usually a 32-pixel by 32-pixel image file in the .ico format. Browsers universally support this format.

Example

You can use this favicon by adding a link element to your page.

<!DOCTYPE HTML>
<html>
<head>
<link rel="shortcut  icon" href="favicon.ico" type="image/x-icon" />
</head>
<body>
  <p>This is a test.</p>
  <a href="http://java2s.com">Visit java2s.com</a>
</body>
</html>

When the HTML page is loaded, the browser will load and display the favicon.

You don't have to use the link element if the favicon is located at the root directory of the web site. Most browsers will automatically request this file when a page is loaded, even without the link element being present.