HTML Tutorial menu

HTML Page Title & Favicon

The page title and the favicon are the first things a visitor sees in the browser tab, in bookmarks and in Google.

The title Element

The <title> element goes inside <head>. Every page needs exactly one.

Example

html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Laptop Prices in Karachi | Ali Computers</title>
</head>
<body>

<h1>Laptop Prices</h1>
<p>Look at the browser tab. The text there comes from the title element.</p>

</body>
</html>
Try it Yourself »

The title is used in many places:

  • The text on the browser tab
  • The default name of a bookmark
  • The blue clickable headline in Google results
  • The heading of the preview when the link is shared

How to Write a Good Title

DoDon't
Put the main topic firstStart with your brand on every page
Keep it around 50 to 60 charactersWrite a whole sentence of 100 characters
Give every page its own titleUse "Home" or "Untitled" on many pages
Describe what the page offersStuff it with repeated keywords

Compare two titles for the same page:

Example

html
<!-- weak -->
<title>Page 2</title>

<!-- strong -->
<title>Web Development Course in Orangi Town | Workownix</title>

A common pattern is "Page topic | Site name". The topic tells people what they get, and the site name builds trust.

What is a Favicon?

A favicon (short for "favourite icon") is the small picture shown beside the title in the browser tab. It also appears in bookmarks, history and on the phone home screen when someone saves your site.

You add it with a <link> element in the head:

Example

html
<link rel="icon" href="favicon.ico">

Favicon File Formats

FormatExampleNotes
ICOfavicon.icoThe oldest format, works everywhere, can hold several sizes
PNGfavicon-32.pngSimple and sharp, set the size with sizes
SVGfavicon.svgOne file that is sharp at any size, supported by modern browsers

A modern head often has a few icon lines, so each device can pick the best one:

Example

html
<head>
  <link rel="icon" href="/favicon.ico" sizes="32x32">
  <link rel="icon" href="/icon.svg" type="image/svg+xml">
  <link rel="apple-touch-icon" href="/apple-touch-icon.png">
</head>
LineWho uses it
favicon.icoOlder browsers and the default request to /favicon.ico
icon.svgModern Chrome, Edge and Firefox
apple-touch-icon.png (180 x 180 pixels)iPhones and iPads when the site is added to the home screen

A Favicon You Can Try

Normally the favicon is a separate file. In this example the icon is written inside the page as an SVG data address, so it works with no file at all. Run it and look at the tab of the result window (if your editor shows tabs).

Example

html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>My Bakery</title>
  <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='45' fill='%23e34c26'/%3E%3C/svg%3E">
</head>
<body>

<h1>Ayesha's Bakery</h1>
<p>This page has a small orange circle as its favicon.</p>

</body>
</html>
Try it Yourself »

Tips for a Good Favicon

  1. Keep the design very simple: one letter or one shape. It is shown at only 16 to 32 pixels.
  2. Use strong colours that stand out on both light and dark browser themes.
  3. Put the files in the root folder of your website, so the paths are short.
  4. After changing the icon, refresh with Ctrl + F5. Browsers keep old favicons for a long time.

Free tools online can turn one square logo into all the favicon sizes for you. Start from a 512 x 512 pixel PNG or an SVG.

Exercise

Exercise

Which line adds a favicon to a page?

Learn HTML with a teacher

Join the Web Development course at Workownix, online or in Orangi Town, Karachi, and get a certificate.

See the course Ask on WhatsApp