Learn to Code
All tracks
Learn to Code

Free lessons from scratch to pro — every language, databases and DevOps.

AboutContactPrivacy PolicyTerms of Use

Your progress is saved in this browser. © 2026 Learn to Code

HTML
HTML
0/10 completed
Beginner
Your first web pageText, links and imagesLists and tablesForms
Intermediate
Semantic HTMLAccessibility basicsSEO and meta tags
Advanced
Images, video and embedsModern HTML: dialog, details and more
Pro
Performance and best practices
Tracks / HTML / Intermediate

SEO and meta tags

SEO (Search Engine Optimization) is about helping search engines find, understand and rank your pages. Much of it starts in your HTML: the <head>, your headings, links and structure.

The essential <head>

html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <!-- 1. Title: the most important on-page SEO element (~50–60 characters) -->
  <title>Learn SQL Joins with Examples | Learn to Code</title>

  <!-- 2. Description: shown under the title in search results (~150–160 characters) -->
  <meta name="description" content="Understand INNER, LEFT and FULL joins with interactive examples you can run in your browser. Free, beginner friendly.">

  <!-- 3. Canonical: the one "official" URL for this content -->
  <link rel="canonical" href="https://learntocode.example/learn/sql/joins">

  <!-- 4. Icons -->
  <link rel="icon" href="/favicon.svg" type="image/svg+xml">
  <link rel="apple-touch-icon" href="/apple-touch-icon.png">
</head>

Writing good titles and descriptions

  • Unique for every page: duplicate titles confuse search engines.
  • Front-load keywords people actually search for: "Learn SQL Joins" beats "Lesson 6".
  • Write for humans. The title and description are your advert in the search results, and their job is to earn the click.

Social sharing: Open Graph and Twitter cards

These control the preview card when someone shares your link on WhatsApp, LinkedIn, X, Slack and so on.

html
<meta property="og:type" content="article">
<meta property="og:title" content="Learn SQL Joins with Examples">
<meta property="og:description" content="Interactive SQL joins tutorial.">
<meta property="og:image" content="https://learntocode.example/og/sql-joins.png">  <!-- 1200×630 -->
<meta property="og:url" content="https://learntocode.example/learn/sql/joins">
<meta name="twitter:card" content="summary_large_image">

Controlling indexing

html
<meta name="robots" content="noindex, nofollow">   <!-- keep this page out of search results -->

Use it for staging sites, thank-you pages and internal search results. Site-wide rules go in /robots.txt:

User-agent: *
Disallow: /admin/
Sitemap: https://learntocode.example/sitemap.xml

A sitemap.xml lists all your pages so crawlers can discover them.

Structured data (JSON-LD)

Structured data describes your content in a machine-readable way. It can earn rich results: star ratings, FAQs, recipe cards and course listings in search.

html
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Course",
  "name": "SQL from scratch to pro",
  "description": "Interactive SQL course with live examples.",
  "provider": { "@type": "Organization", "name": "Learn to Code" }
}
</script>

Test it with Google's Rich Results Test.

On-page SEO checklist

HTML · CSS · live preview
Preview
  1. One <h1> that describes the page, with a logical h2/h3 structure.
  2. Descriptive URLs: /learn/sql/joins beats /page?id=123.
  3. Internal links with meaningful anchor text.
  4. Alt text on images.
  5. Fast and mobile-friendly: Google ranks the mobile version of your site, and speed (Core Web Vitals) matters.
  6. HTTPS everywhere.
  7. Great content that answers the searcher's question better than anything else. No meta tag beats this.

The keywords meta tag (<meta name="keywords">) has been ignored by Google for over a decade. Don't bother.

Single-page apps and SEO

Sites rendered entirely by JavaScript (like a plain React app) can be slower for search engines to index, and every page may share the same <title>. Solutions:

  • Update document.title and the meta tags on each route.
  • Use server-side rendering or static generation (Next.js, Astro, Remix) so every URL serves full HTML.

Practice

Write a complete <head> for a page about "Docker Compose tutorial for beginners" on a site of your choice. Include the title, description, canonical URL, Open Graph tags and JSON-LD with @type: "Article".

✎ Check your understanding

1.Which element most strongly influences how a page appears in search results?

2.What is rel="canonical" for?

← Accessibility basics