Draft in development; may change radically at any time.
A favicon is a graphic image (icon) associated with a particular Web page and/or Web site. Many recent user agents (such as graphical browsers and newsreaders) display them as a visual reminder of the Web site identity in the address bar or in tabs. The wikipedia includes an article about favicons [FAVICON-WIKIPEDIA].
To add a favicon to your Web site, you'll need both an image and a method for specifying that the image is to be used as a favicon. This document explains the method preferred by W3C for specifying the favicon. There is another common method that is illustrated below, with an explanation of why that method is inconsistent with some principles of Web architecture. Both methods only apply to HTML and XHTML, one of the limitations discussed below.
This document does not discuss in detail how to create a favicon image. However, the format for the image you have chosen must be 16x16 pixels or 32x32 pixels, using either 8-bit or 24-bit colors. The format of the image must be one of PNG (a W3C standard), GIF, or ICO.
rel
attribute value
defined in a profileThe first approach for specifying a favicon is to use the rel
attribute value "icon" and to define what the value means via a profile; profiles are discussed in more detail
below. In this HTML 4.01 example, the favicon identified via the URI
http://example.com/myicon.png
as being a favicon:
<!DOCTYPE html
PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en-US">
<head profile="http://www.w3.org/2005/10/profile">
<link rel="icon"
type="image/png"
href="http://example.com/myicon.png">
[…]
</head>
[…]
</html>
The XHTML 1.0 version looks very similar:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en-US"
lang="en-US">
<head profile="http://www.w3.org/2005/10/profile">
<link rel="icon"
type="image/png"
href="/somewhere/myicon.png" />
[…]
</head>
[…]
</html>
A second method for specifying a favicon relies on using a predefined URI to identify the image: "/favicon", which is relative to the server root. This method works because some browsers have been programmed to look for favicons using that URI. This approach is inconsistent with some principles of Web architecture and is being discussed by W3C's Technical Architecture Group (TAG) as their issue siteData-36. To summarize the issue: The Web architecture authorizes site managers to manage their URI space (for a given domain name) as they see fit. Conventions that do not represent community agreement and that reduce the options available to a site manager do not scale and may lead to conflict (since there is no well-known list of these predefined URIs). One practical consideration illustrates the problem: many users have Web sites even though they do not have their own domain name. These users cannot specify favicons using the second method if they cannot write to the server root. However, they can use method one to specify a favicon since it is more flexible and does not constrain the site manager to use a single favicon at a single place on the site.
There are a few other well-known encroachments on URI space, including the "robots.txt" file and the location of a P3P privacy policy. The Technical Architecture Group is exploring alternatives that do not impinge on URI space without license.
Loosely speaking, a profile is a definition of set of
terms. Ideally, a profile includes both machine-readable information
and human-readable information. In HTML 4.01 and XHTML 1.0, a few
attributes such as the rel
attribute do not have a predefined set of
values. Instead, the author can provide values according to need, and
then use a profile to explain what the values mean. In our case, we
have recommend that authors use the value "icon" and a profile that
explains that "when we say icon, we mean 'this is a favicon.'"
In Method 1 above, we use the rel
attribute with the
LINK
element and choose a profile with the profile
attribute
on the HEAD element.
We defined a profile which you can freely use for your own sites.
There are several limitations to the approaches described above, including the preferred method (which is why the TAG continues to work on the question):
rel
. For more information on the use of profiles
in HTML and XHTML, see GRDDL
[GRDDL].The following QA Interest Group participants and W3C staff have contributed significantly to the content of this document: Dominique Hazaël-Massieux (W3C), Chris Lilley (W3C), and Olivier Théreaux (W3C).