A favicon, short for "favorite icon," is a small image that represents a website. It typically appears in the browser tab and bookmarks. To add a favicon to your HTML document, follow these steps:
Create Your Favicon:
Place Favicon in Your Project Directory:
images
).Add the Favicon Link in the <head>
of Your HTML Document:
<head>
section.<head>
section:html<link rel="icon" href="path/to/your/favicon.ico" type="image/x-icon">
Replace "path/to/your/favicon.ico"
with the actual path to your favicon image.
If your favicon is in a different format (e.g., PNG), you can use:
html<link rel="icon" href="path/to/your/favicon.png" type="image/png">
If you want to support multiple sizes and resolutions, you can use the following code, specifying different sizes:
html<link rel="icon" href="path/to/your/favicon-16x16.png" sizes="16x16" type="image/png">
<link rel="icon" href="path/to/your/favicon-32x32.png" sizes="32x32" type="image/png">
Save and Test:
Remember to replace "path/to/your/favicon.ico" with the actual path to your favicon image. If your project is hosted online, ensure that the favicon file is accessible from the web by providing the correct path.