Meta Tags & SEO — HTML

Meta tags hold information about the page. They go in <head> and don't show on the page. Every page needs <meta charset="UTF-8">, a viewport meta so it fits…

You share a link in a WhatsApp group, and a small card appears with a picture and a title. But you only pasted the address. How does WhatsApp know which picture to use?

From meta tags: tags inside <head> that hold information about the page. They don't show on the page. The browser and Google read them, and so do chat apps when your link is shared.

What every page needs in <head>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Mrs. Sri's Stall</title>
  <meta name="description" content="Coconut rice, black coffee and warm sweet tea.">
</head>

A meta with name always comes with content: name says what the information is about, and content holds its value. None of this is visible on the page. The page still shows only the content of <body>.

Preview cards with Open Graph

When a link is shared, WhatsApp, Facebook and LinkedIn build a preview card from the Open Graph meta tags. Open Graph is a set of meta tags made to fill that card:

<meta property="og:title" content="Mrs. Sri's Stall">
<meta property="og:description" content="Coconut rice breakfast from $2.">
<meta property="og:image" content="https://example.com/stall/og.jpg">
<meta property="og:type" content="website">

⚠️ Meta tags in the wrong place, empty, or all the same

TL;DR: Meta tags hold information about the page. They go in <head> and don't show on the page. Every page needs <meta charset="UTF-8">, a viewport meta so it fits on phones, and a <title>. Add a description meta for the summary on Google. For the preview card that chat apps show when a link is shared, use Open Graph: <meta property="og:..." content="..."> for og:title, og:description, og:image and og:type.

⚡ Information that doesn't show

Write:

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Mrs. Sri's Stall</title>
  <meta name="description" content="Coconut rice, black coffee and warm sweet tea.">
</head>

Meaning: Meta tags hold information about the page. All of this goes in <head> and doesn't show on the page. charset="UTF-8" makes symbols like © show correctly. <title> shows in the tab and as the title in Google results. description is the summary often shown under it.

⚡ Fit on a phone screen

Guess first: without the viewport meta, how does your page look on a phone?

The text is very small. The phone browser treats the page as wide as a laptop screen, then shrinks it.

Meaning: The viewport meta makes the page as wide as the phone's screen.

⚡ Preview cards with Open Graph

Write:

<meta property="og:title" content="Mrs. Sri's Stall">
<meta property="og:image" content="https://example.com/stall/og.jpg">

Meaning: When a link is shared, WhatsApp and Facebook read these meta tags to build a preview card (a small card with the title and picture). These meta tags are called Open Graph: they use property, not name, the value of property starts with og:, and the text goes in content.

What you will learn