HTML content Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The content attribute on <meta> holds the value that goes with name or http-equiv. Put these tags in <head>.

It does not draw text on the page. Do not confuse it with contenteditable or the DOM textContent property.

Baseline · Widely available.

Not deprecated and not experimental. Standard <meta> attribute across modern browsers.

HTML Syntax

syntax.html
<meta name=" key" content="value">

Or pair with http-equiv instead of name. <meta> is a void element — no closing tag.

Attribute Values

content is a string. Its meaning depends on the paired attribute:

Paired withTypical content valueTry it
name="description"Short page summary for search / social previewsTry it
name="viewport"e.g. width=device-width, initial-scale=1.0Try it
name="theme-color"A CSS color; optional media queryTry it
http-equiv="refresh"Delay and optional URL, e.g. 5;url=/homeTry it

Live Preview

Pick a name and edit content. Meta tags are not visible on the page — this preview shows the markup you would put in <head>.

Study-only markup builder. Nothing is injected into this page’s real <head>.

Generated meta
<meta name="description" content="Learn the HTML content attribute on meta elements.">

name="description"

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Meta description

Pair name="description" with a clear summary in content.

HTML
<head>
  <meta charset="UTF-8">
  <title>HTML content Attribute</title>
  <meta
    name="description"
    content="Learn the HTML content attribute on meta elements.">
</head>
Try It Yourself

How It Works

  1. name labels the kind of metadata (description).
  2. content stores the actual summary string.
  3. Place in head with charset and title for a complete document start.
  4. Plain text — keep it concise; no HTML markup inside the value.

Example 2 — Viewport content

Mobile-friendly pages set viewport rules as the content value.

HTML
<head>
  <meta charset="UTF-8">
  <meta
    name="viewport"
    content="width=device-width, initial-scale=1.0">
  <meta name="theme-color" content="#0f172a">
</head>
Try It Yourself

How It Works

  1. viewport tells mobile browsers how to size the layout viewport.
  2. content lists directives separated by commas.
  3. theme-color suggests a UI chrome color; value is a CSS color in content.
  4. media can limit theme-color (for example dark mode) — see the media attribute.

Example 3 — http-equiv refresh

content supplies the pragma value when using http-equiv. Prefer real HTTP redirects when possible.

HTML
<head>
  <!-- Study only: prefer HTTP redirects in production -->
  <meta http-equiv="refresh" content="5;url=https://example.com/">
</head>
Try It Yourself

How It Works

  1. http-equiv="refresh" asks the browser to treat the meta like a refresh header.
  2. content starts with seconds; add ;url=... to redirect.
  3. Accessibility caution — unexpected redirects can confuse users; offer a normal link too.
  4. Server redirects are usually better for permanent moves.

Edge Cases & Pitfalls

Most confusion comes from treating content like visible page text.

scope

Meta only (for this attribute)

content on <meta> is metadata. Visible copy belongs in body elements, not in this attribute.

naming

Not contenteditable

contenteditable makes elements editable. Different feature, similar name.

pair

Needs name or http-equiv

Alone, content has nothing to describe. Always pair it with the matching attribute.

refresh

Avoid surprise redirects

Auto-refresh can trap users and hurt accessibility. Prefer HTTP redirects and clear links.

charset

Charset uses a different attribute

Character encoding uses charset on meta — not content.

Browser Support

content is an HTML attribute for <meta> in the browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

content

Widely available with meta across modern browsers. Support for individual name or http-equiv values can vary by feature.

96% Global support (approx.)
Google Chrome All modern
Full support
Mozilla Firefox All modern
Full support
Apple Safari All modern
Full support
Microsoft Edge All modern
Full support
Opera All modern
Full support
Samsung Internet All modern
Full support
Internet Explorer Supported
Supported
content Widely supported

Bottom line: Safe for standard meta name/content and common http-equiv uses. Prefer HTTP redirects over meta refresh when you can.

Key Takeaways

  • Role: value half of a meta name/value (or http-equiv) pair.
  • Element: <meta> in <head> — not visible body text.
  • Common uses: description, viewport, theme-color, refresh.
  • Not the same as contenteditable or textContent.

One line: content is the meta value — pair it with name or http-equiv.

Frequently Asked Questions

On a meta element, content holds the value that pairs with name or http-equiv — for example a page description string or a viewport definition.
The HTML content attribute in this sense is for meta. It is not how you set visible text on div, p, or button elements.
No. content is a meta value attribute. contenteditable is a global attribute that makes an element’s text editable in the page.
Treat it as plain text. Tags inside the attribute value are not rendered as markup on the page.
Examples: a short description for name="description", width=device-width for name="viewport", and timed redirect strings for http-equiv="refresh".
Select the meta element, then use meta.content = "new value" or setAttribute("content", "new value").

Next: contenteditable

Make an element’s text editable directly in the browser.

contenteditable tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful