Codectionary / Developer documentation / HTML

<meta>

The <meta> element provides metadata about the HTML document that is not displayed on the page itself — used for things like character encoding, viewport configuration, page descriptions for search engines, and social media preview data. Meta tags live inside the <head> and are void (self-closing) elements.

Syntax

<meta name="description" content="Page description">

Examples

Essential Meta Tags

The meta tags almost every page should include.

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Learn web development with Codectionary.">

Social Media Preview (Open Graph)

Meta tags that control how a link looks when shared on social media.

<meta property="og:title" content="Codectionary - Learn to Code">
<meta property="og:description" content="An interactive platform for learning web development.">
<meta property="og:image" content="https://codectionary.com/preview.png">

SEO and Robots

Controlling how search engines index the page.

<meta name="robots" content="index, follow">
<meta name="keywords" content="html, css, javascript, learn to code">

Attributes

  • charset (string): Declares the document's character encoding, typically UTF-8
  • name (string): Identifies the type of metadata, e.g. viewport, description, author
  • content (string): The value associated with the name or property attribute
  • property (string): Used for Open Graph metadata (og:title, og:image, etc.)

Best practices

  • Always include charset and viewport meta tags as early as possible in <head>
  • Write a unique, concise description for each page (roughly 150-160 characters) to improve search engine snippets
  • Add Open Graph meta tags so links look good when shared on social platforms
  • Do not overload the description with keywords — write for humans first

At a glance

Purpose
Structure and meaning for web content
File extension
.html · .htm
Runs in
Web browsers
Usually used with
CSS and JavaScript

Specifications & further reading

Related HTML documentation