KodingKaro
HTML · Intermediate · HTML Metadata and SEO

Titles, descriptions, viewport, and canonical URLs

Document metadata helps browsers and search tools identify a page and gives mobile layouts the correct viewport.

✓ What you will learn in this topic

  • Explain the purpose of Titles, descriptions, viewport, and canonical URLs in a real HTML document.
  • Choose and apply the elements shown in both examples.
  • Recognize the specific mistake described in this lesson.

Concept explanation

A page title should be unique, concise, and faithful to its visible topic. A meta description can summarize the page for search previews, though search engines may choose other text. Viewport metadata prevents a mobile browser from laying out the page as a wide desktop canvas. A canonical link identifies the preferred URL when equivalent copies exist; it should use the correct absolute URL and is not a substitute for fixing duplicate content.

Syntax

Place title and meta elements in head; use a link with rel=\"canonical\" for the preferred absolute page URL.

Example 1: a small page

The title labels the page; the description and viewport serve different contexts.

<title>Weekend pottery classes | Clay House</title>
<meta name=\"description\" content=\"Compare beginner pottery classes at Clay House.\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">

Expected result: The tab uses the descriptive title and mobile browsers use the device width for the layout viewport.

Example 2: a practical page

The canonical points to the preferred page address, while the description accurately summarizes it.

<head>
  <title>Opening hours | Riverside Museum</title>
  <link rel=\"canonical\" href=\"https://example.com/visit/hours\">
  <meta name=\"description\" content=\"Check today’s opening hours and holiday schedule for Riverside Museum.\">
</head>

Expected result: The document has a unique title, a search summary, and one preferred URL.

Common mistakes

Do not copy the same title and description to every page or declare a canonical URL that points to a different content page.

Best practices

Give each page a distinct, accurate title and description, ensure canonical URLs are absolute and correct, and keep visible content aligned with metadata.

Practice exercise

Write the head section for a unique event page with title, description, viewport, canonical URL, social preview metadata, and a favicon reference.

Lesson summary

  • Metadata should be unique, accurate, and consistent with the page visitors will read.
  • Give each page a distinct, accurate title and description, ensure canonical URLs are absolute and correct, and keep visible content aligned with metadata.

Knowledge check

What should a canonical URL identify?

Show the explanation

It should identify the preferred absolute URL for the same or substantially equivalent page content.

Practical example

html
<title>Weekend pottery classes | Clay House</title>
<meta name=\"description\" content=\"Compare beginner pottery classes at Clay House.\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">

Expected result:

The tab uses the descriptive title and mobile browsers use the device width for the layout viewport.

Hands-on practice task

Write the head section for a unique event page with title, description, viewport, canonical URL, social preview metadata, and a favicon reference.

In this section

Other lessons in HTML Metadata and SEO

Broaden your knowledge

Related learning topics