A favicon (short for favorite icon) is a small, iconic image that represents a
website,
typically displayed in the browser's address bar, tabs, bookmarks, and other places where website icons
are
shown.
1. Create Your Favicon:
Design a small square image (usually 16x16 pixels or 32x32 pixels) that represents your
website or
brand. Common formats include .ico, .png, and .gif.
2. Save Your Favicon:
Save your favicon image file to your project directory. Ensure the filename is simple and
memorable,
like favicon.ico.
3. Link Your Favicon in HTML:
Add a <link> tag inside the <head>section of your HTML
document to
link to your favicon file. The rel="icon" attribute specifies the relationship between the
document
and
the favicon, and the type attribute indicates the file format.
If your favicon is in PNG format (which is common for modern designs), you can use this code
instead:
If your favicon is in PNG format (which is common for modern designs), you can use this code
instead:
4. Place the Favicon File:
Ensure the favicon file (favicon.ico or favicon.png) is placed in the root directory of your
website
or
in a specific directory (/images, /icons, etc.) that you reference correctly in the
tag.
5. Verify Favicon Display:
After adding the favicon to your HTML, save the file and open your website in a browser. You
should
see
your favicon displayed in the browser's tab and address bar.
6. Consider Different Devices:
For better compatibility and appearance on different devices (such as high-resolution
screens or
mobile devices), you might want to provide multiple sizes of your favicon and use the
appropriate
<link>tags with the sizes attribute.