Skip to the workspace
Pebellslearn by building
Document Structure  ›  Lesson

The title and meta Tags

meta 12 minThe title element names the page for tabs, bookmarks and search results, while meta tags declare the character encoding, the mobile viewport and a page description.

html / The title and meta Tags

Explore each scene at your own pace.

01 · The rule

The rule

The title and meta Tags

The title element names the page for tabs, bookmarks and search results, while meta tags declare the character encoding, the mobile viewport and a page description.

Give the page a useful title, character encoding and viewport configuration.

You search for a recipe and see a list of results: a blue line of text and a short grey summary under each. Both of those usually come from a page's head. So does whether the page's accented letters show correctly and whether it fits your phone screen. A handful of tags do all of that.

The rule

Encoding first, viewport next, then title and description.

These four lines belong in almost every page's head:

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Masala Chai at Home | Kettle &amp; Leaf</title>
  <meta name="description" content="A simple masala chai recipe with fresh ginger and whole spices, ready in ten minutes.">
</head>
  • <meta charset="utf-8"> tells the browser how to turn the file's bytes into characters. UTF-8 covers practically every writing system and emoji. Put it first, because the browser needs to know the encoding before reading much text. Without it you may see garbage like é instead of é.
  • The viewport meta tag tells phones to lay the page out at the device's real width. Without it, mobile browsers pretend to be a wide desktop screen and shrink everything, so text becomes tiny.
  • <title> names the page. It appears in the browser tab, in bookmarks and history, and usually as the clickable line in search results. Make it specific: "Masala Chai at Home" beats "Home". Every page on a site should have its own title.
  • The description meta tag is a one or two sentence summary. Search engines often use it as the grey text under the title, so write it for a human deciding whether to click.

Notice the pattern: meta is a void element, and most meta tags pair a name with a content.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.