HTML SEO and Meta Tags
What is SEO?
SEO (Search Engine Optimization) means making your page easy for search engines like Google and Bing to find, understand, and show in their results.
Meta tags help with this. They are tags in the head section of a page, that give information about the page. Visitors do not see them on the page itself, but search engines, browsers, and social media sites read them.
Example
<head>
<title>Learn HTML</title>
<meta name="description"
content="Free HTML tutorial with examples.">
</head>
Title and Description
These two tags decide what people see about your page in search results, so they are the most important ones to get right.
The title Tag
The title is shown as the blue clickable headline in search results and in the browser tab.
Example
<title>HTML Tables Tutorial - Learn with Examples</title>
Things to do:
- Give every page its own, unique title
- Put the most important words first
- Keep it to about 50-60 characters, so it is not cut off
The meta Description
The description is often shown as the short text under the title in search results. It does not change your ranking directly, but a good description makes more people click.
Example
<meta name="description" content="Learn how to create HTML tables with rows,
columns, and headers. Try every example yourself in our online editor.">
Things to do:
- Describe what the page offers in one or two sentences
- Keep it to about 150-160 characters
- Write a different description for each page
Note: Search engines sometimes write their own snippet instead of using your description, for example when another part of the page fits the search better.
Other Important Head Tags
| Tag | What it does |
|---|---|
| <meta charset="UTF-8"> | Makes sure all characters show correctly |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | Makes the page fit phone screens. Search engines favor mobile-friendly pages |
| <html lang="en"> | Tells search engines and screen readers the language of the page |
| <link rel="canonical" href="..."> | Names the main address of a page that can be reached at more than one URL |
| <meta name="robots" content="..."> | Tells search engines whether to show the page and follow its links |
Canonical links
The same page can often be reached at several addresses, like example.com/shoes and example.com/shoes?color=red. The canonical link tells search engines which address is the real one, so they do not treat the others as duplicates:
Example
<link rel="canonical" href="https://example.com/shoes">
Robots
By default, search engines show your pages and follow your links. Use the robots tag only when you want something else:
Example
<!-- Do not show this page in search results -->
<meta name="robots"
content="noindex">
<!-- Do not show it, and do not follow its links -->
<meta name="robots" content="noindex, nofollow">
This is useful for pages like a thank-you page or an internal search results page.
Open Graph
When someone shares a link on Facebook, LinkedIn, Slack, or in a chat app, a small preview card often appears with a picture, a title, and a short text.
Open Graph tags decide what that card shows. Without them, the site has to guess, and the preview may show the wrong image or no image at all.
Example
<meta property="og:title" content="HTML Tables Tutorial">
<meta
property="og:description" content="Learn how to create HTML tables with
examples.">
<meta property="og:image"
content="https://example.com/images/tables.png">
<meta property="og:url"
content="https://example.com/html/tables">
<meta property="og:type"
content="article">
Note: Open Graph tags use property, not name.
| Value | What it sets |
|---|---|
| og:title | The title on the card |
| og:description | The short text under the title |
| og:image | The picture. Use a full URL, starting with https:// |
| og:url | The main address of the page |
| og:type | The kind of content, like website or article |
| og:site_name | The name of your website |
Tips for og:image
- A size of 1200x630 pixels works well on most sites
- Keep important text and logos away from the edges, since some sites crop the image
- Use a full address, like https://example.com/image.png, not a relative path
X (Twitter) Cards
X reads Open Graph tags too, but it needs one extra tag to show a large image:
Example
<meta name="twitter:card" content="summary_large_image">
Test your preview
Most social sites save a copy of the preview. If you change your tags, use the site's link preview or debugging tool to refresh it.
A Complete Example
Here is a <head> section with all the tags from this page:
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Search engines -->
<title>HTML Tables Tutorial - Learn with
Examples</title>
<meta name="description" content="Learn how to
create HTML tables with rows, columns, and headers.">
<link
rel="canonical" href="https://example.com/html/tables">
<!--
Social media -->
<meta property="og:title" content="HTML Tables
Tutorial">
<meta property="og:description" content="Learn how to
create HTML tables with examples.">
<meta property="og:image"
content="https://example.com/images/tables.png">
<meta
property="og:url" content="https://example.com/html/tables">
<meta
property="og:type" content="article">
<meta property="og:site_name"
content="Example Tutorials">
<meta name="twitter:card"
content="summary_large_image">
</head>
SEO - Beyond Meta Tags
Meta tags help, but search engines mostly look at the content of your page.
Good HTML makes the content easy to understand. Follow these rules:
- One <h1> per page that says what the page is about, then <h2> and <h3> in order
- Semantic elements like <main>, <nav>, and <article>, so the structure is clear
- Alt text on images, so search engines know what each image shows
- Descriptive link text, like "Read the HTML tutorial" instead of "Click here"
- Fast loading, since slow pages can rank lower
What about the <meta name="keywords"> tag?
You may see this tag in older code:
Example
<meta name="keywords" content="html, tables, tutorial">
Search engines do not use it for ranking anymore. It was misused so much in the past that search engines stopped trusting it. You can leave it out.