Home HTML Attributes content HTML content Attribute Definition
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.
Syntax
HTML Syntax <meta name=" key " content="value ">
Or pair with http-equiv instead of name. <meta> is a void element — no closing tag.
Values
Attribute Values content is a string. Its meaning depends on the paired attribute:
Paired with Typical content value Try it name="description"Short page summary for search / social previews Try itname="viewport"e.g. width=device-width, initial-scale=1.0 Try itname="theme-color"A CSS color; optional media query Try ithttp-equiv="refresh"Delay and optional URL, e.g. 5;url=/home Try it
Try 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>.
Code
HTML Examples Short, copy-ready snippets. Use Try It Yourself for a live editor.
1. Description 2. Viewport 3. Refresh Example 1 — Meta description Pair name="description" with a clear summary in content.
<head>
<meta charset="UTF-8">
<title>HTML content Attribute</title>
<meta
name="description"
content="Learn the HTML content attribute on meta elements.">
</head> Meta tags live in <head> and are not shown as page text. Search tools may use this description.
<meta name="description" content="Learn the HTML content attribute on meta elements."> How It Works name labels the kind of metadata (description).content stores the actual summary string.Place in head with charset and title for a complete document start.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.
<head>
<meta charset="UTF-8">
<meta
name="viewport"
content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#0f172a">
</head> Viewport and theme-color meta tags configure the browser chrome — they do not print on the page.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#0f172a"> How It Works viewport tells mobile browsers how to size the layout viewport.content lists directives separated by commas.theme-color suggests a UI chrome color; value is a CSS color in content.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.
<head>
<!-- Study only: prefer HTTP redirects in production -->
<meta http-equiv="refresh" content="5;url=https://example.com/">
</head> This demo does not start a real redirect. The markup shape is:
<meta http-equiv="refresh" content="5;url=https://example.com/"> Meaning: wait 5 seconds, then go to the URL.
How It Works http-equiv="refresh" asks the browser to treat the meta like a refresh header.content starts with seconds; add ;url=... to redirect.Accessibility caution — unexpected redirects can confuse users; offer a normal link too.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.
Compatibility
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.
Remember
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 What does the HTML content attribute do? 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.
Which element uses content? The HTML content attribute in this sense is for meta. It is not how you set visible text on div, p, or button elements.
Is content the same as contenteditable? No. content is a meta value attribute. contenteditable is a global attribute that makes an element’s text editable in the page.
Can content contain HTML tags? Treat it as plain text. Tags inside the attribute value are not rendered as markup on the page.
What are common content values? Examples: a short description for name="description", width=device-width for name="viewport", and timed redirect strings for http-equiv="refresh".
How do I change meta content with JavaScript? Select the meta element, then use meta.content = "new value" or setAttribute("content", "new value").
CODETOFUN NEWS
Stay Ahead in Tech Get the latest IT news, programming updates, and technology trends directly on your phone.
About the author Developer, cloud engineer, and technical writer
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
Helpful Share Copy link Suggestion