CHAPTER 43 · HTML

Page settings: title, metadata and a browser-tab icon

Explain the information in head one part at a time. Give each page a useful title and description without confusing them with visible content.

Download example files (ZIP)

The label on a notebook

A notebook cover tells you what is inside before you read a page. A web document has similar identifying information in head. Metadata means information about the document. Some of it affects browser behaviour; some helps tools understand the page. It is not an extra visible introduction.

The body still needs a useful heading and actual content. A description in head cannot replace an explanation the reader needs on the page.

Title: a name for the whole document

Title supplies a text name commonly shown in the browser tab, history and bookmarks. Use one clear title inside head. A title such as Notebook Workshop | Practice Club identifies both the topic and its context; Page 1 does little to help someone recognise it among several tabs.

H1 is the visible main heading in body. It has a different job even when its wording resembles the title. Do not place headings or formatting tags inside title. Each separate page should have a title that actually describes that page.

Charset and the saved file must agree

Meta charset=UTF-8 tells the browser the intended character encoding. Save the source file as UTF-8 too. Encoding is the agreement for reading stored characters; a declaration alone cannot repair bytes saved using a different agreement. Keep the declaration near the start of head, within the first 1024 bytes.

This helps pages include names, Indian language text and symbols without treating every non-English character as an error. The document's lang attribute is different: lang=en states the language, not the encoding.

Read a name-and-content metadata pair

In meta name=description, name says which kind of information this is and content holds its value. Write an accurate short summary of this particular page. Meta name=author can identify its author, but it does not create a visible author byline or establish ownership.

HTML fragment — part of a document
<meta name="description" content="Practice saving and opening a small HTML page.">
<meta name="author" content="Practice Club">

Meta is a void element, so it does not wrap a paragraph or need a closing meta tag. The words in content are an attribute value; keep them quoted.

Descriptions help; they do not promise search placement

A search engine may use a useful description in a result snippet, or select text from the page instead. Do not promise an exact snippet, a fixed display length or a ranking because you added this tag. Write honest content for readers first.

The keywords meta tag is not a shortcut to Google ranking; Google does not use it for web search ranking. Repeating a long list of keywords does not substitute for a helpful page. Robots metadata can request indexing behaviour from cooperating crawlers, but noindex does not make a page private or restrict who can open its URL.

Viewport: let layout start at the device width

Meta name=viewport with content="width=device-width, initial-scale=1" asks a mobile browser to use the device width for its layout viewport and start at the normal scale. It does not make an oversized image or a fixed-width layout automatically fit. We will practise those changes in Chapter 45.

Do not disable user zoom to make a design appear tidier. People may need to enlarge text. The viewport setting and readable CSS must work together.

Link a favicon: a small tab icon

A favicon is a small icon browsers can show for a page, often beside its title. Put link rel=icon in head. Rel says the relationship, href gives the file path, and type can describe the image format. Our example reuses an original lesson SVG, not a remote image.

Save the supplied images folder beside the HTML file. The icon is requested by the standalone document; it is not an image placed in body and does not replace a logo's alternative text. Browsers cache icons and support formats differently, so an unchanged tab icon does not always mean the path is wrong. The embedded preview does not change the surrounding tutorial's tab icon.

Other head elements to recognise

Style holds CSS; link rel=stylesheet connects a CSS file; script loads or contains JavaScript. We introduce CSS next and cover scripts separately. Base can change how relative links resolve across a document. Adding one casually can break previously correct local paths, so our examples deliberately omit it.

Meta http-equiv is not a general way to set any server security or caching header. Avoid automatic refreshes that interrupt reading; use real server redirects when a site genuinely needs a moved-page response. Do not copy a block of head tags without understanding each setting.

Follow the idea

Information about the page
  1. 1Title: identify the document
  2. 2Charset: agree how characters are read
  3. 3Description: summarise this page
  4. 4Icon and viewport: browser resources and layout settings

Metadata supports the document; it does not replace useful visible content.

Complete program: metadata-notice.html

Save this as metadata-notice.html. Open it in your browser.

metadata-notice.html
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Notebook Workshop | Practice Club</title>
    <meta
      name="description"
      content="A fictional student workshop for practising clear HTML links and explaining a saved page."
    />
    <meta name="author" content="Practice Club" />
  </head>
  <body>
    <h1>Notebook workshop</h1>
    <main>
      <p>Bring a saved HTML page to our fictional link practice session.</p>
      <p>
        The browser tab describes this page; metadata describes it without adding another visible
        paragraph.
      </p>
    </main>
  </body>
</html>
Browser previewDocument title: Notebook Workshop | Practice Club

This preview shows the example in a browser. Save the complete code in local files to test links between pages and downloads. Same-page section links work here.

Expected result: the tab title identifies the workshop, while body shows its main heading and two paragraphs. The description and author values do not appear as extra paragraphs. They can be inspected in the saved source.

Complete program: icon-notice.html

Save this as icon-notice.html. Open it in your browser.

icon-notice.html
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>File Check | Practice Club</title>
    <meta
      name="description"
      content="A short fictional checklist for saving and opening a practice HTML file."
    />
    <link rel="icon" type="image/svg+xml" href="images/practice-mark.svg" />
  </head>
  <body>
    <h1>Check your practice file</h1>
    <main>
      <p>Confirm the file ends in .html, then open it in your browser.</p>
      <p>
        When opened as a normal page, this example requests the supplied practice icon for its tab.
      </p>
    </main>
  </body>
</html>
Browser previewDocument title: File Check | Practice Club

This preview shows the example in a browser. Save the complete code in local files to test links between pages and downloads. Same-page section links work here.

Expected result: a file-check page with a different title and description. Keep images/practice-mark.svg at the given path. Open as a normal page to check the tab icon; the tutorial preview keeps its own surrounding tab information.

Problem and solution

Problem: a student changes title and expects the large visible heading to change too.

Solution: update the body h1 separately. Title names the document for browser and tool use; h1 introduces visible page content.

Common mistakes and useful tips

  • Do not use one vague title for every page.
  • Do not place visible paragraphs in head.
  • Save the file as UTF-8 as well as declaring it.
  • Do not promise a ranking from metadata.
  • Do not treat noindex as password protection.
  • Do not disable zoom or paste unexplained base and refresh tags.

Practice questions

  1. Where does title belong?
  2. Which tag supplies a visible main heading?
  3. What does content hold in description metadata?
  4. Will a meta description always be the search snippet?
  5. Does rel=icon place a picture inside the body?
  6. Open both complete examples as normal pages and compare their tabs and source. What changes without becoming a visible paragraph?
Check your practice answers
  1. Inside head.
  2. H1 in body.
  3. The actual description value.
  4. No. A search engine can choose other relevant page text.
  5. No. It identifies an icon resource for browser use.
  6. The document titles, descriptions and icon request differ. Metadata is document information, not extra body prose.

Interview questions

How do title and h1 differ?

Title identifies the document, commonly in a browser tab. H1 is the visible main heading. Both should describe the actual page.

What is a meta description for?

It supplies a concise page summary that tools may use. It does not guarantee a ranking or exact search-result wording.

Does noindex make content private?

No. It is an indexing request for cooperating crawlers. Access control requires a different mechanism.

Why avoid an unexplained base element?

It changes resolution of relative addresses throughout the page, potentially including links and fragment behaviour. Omit it unless its effect is deliberate and tested.

Quick revision

  • Keep head information separate from body content.
  • Give every document a useful title.
  • Use accurate metadata and matching encoding.
  • Check resource paths and preserve zoom.