HTML for Web Development

0% completed

Previous
Next
HTML Favicons

In this lesson, you'll learn what favicons are, why they are important, and how to add them to your webpage using HTML.

What Is a Favicon?

A favicon (short for "favorite icon") is a small image or icon that represents your website. Favicons appear in several places, such as:

  • Browser tabs
  • Bookmarks or favorites lists
  • Browser history

They help users quickly identify your site and add a professional touch to your website.

Adding a Favicon Using HTML

Favicons are added to your webpage through the <link> element inside the <head> section of your HTML document.

Basic Syntax:

<link rel="icon" type="image/png" href="path/to/favicon.png">
  • rel="icon": Specifies that the linked file is a favicon.
  • type="image/png": Indicates the file type (could be image/png, image/gif, image/x-icon, etc.).
  • href: The path to the favicon file.

Considerations and Variations

  • File Format: Favicons are commonly available in PNG, GIF, or ICO formats. The ICO format is widely supported and can contain multiple sizes.
  • Sizes: Favicons are typically small (16×16 pixels or 32×32 pixels). You can also provide different sizes for various devices.
  • Alternate Link: Some sites use additional <link> tags for compatibility with different platforms (like Apple devices). For instance:
    <link rel="apple-touch-icon" href="path/to/apple-touch-icon.png">

Example: Adding a Favicon

Below is a complete HTML example that shows how to add a favicon to a webpage:

HTML

. . . .

Explanation:

  • The <link rel="icon"> element in the <head> section tells the browser where to find the favicon file.
  • We specify the image type using the type attribute.

Understanding how to add and manage favicons is a small yet essential part of building a well-rounded website. In our next lesson, we'll cover HTML Page Redirection to explore how you can automatically direct users from one page to another.

.....

.....

.....

Like the course? Get enrolled and start learning!
Previous
Next