How to set up a favicon in HTML
A favicon is a small icon that appears on the browser tab or address bar of a website. It helps to identify the website and differentiates it from other tabs. Here’s how to use it in HTML:
First, create your favicon and save it as a .ico file. Then, add the following HTML code to the head section of your webpage:
<link rel="icon" type="image/x-icon" href="favicon.ico">
The “rel” attribute tells the browser that this is a shortcut icon. The “type” attribute specifies the file type, in this case, an .ico file. The “href” attribute indicates the path to the favicon on your server.
Here’s an example usage in HTML:
<html> <head> <title>My Website</title> <link rel="icon" type="image/x-icon" href="favicon.ico"> </head> <body> <h1>Welcome to my website!</h1> <p>This is some content on my website.</p> </body> </html>
Note that the “href” attribute should point to the location of your actual favicon file.
Here’s an example of a website that effectively uses a favicon: Google
Overall, favicons are a small but important detail that can greatly enhance the user experience on a website.
Written by: Michael from Beginnrtuts.com 01-06-2023 Written in: HTML tutorials