👀 Live Preview
Typical meta tags inside head (not visible on the page, but read by browsers and crawlers):

The <meta> tag in HTML plays a crucial role in providing metadata about a document. Understanding its usage and attributes is essential for enhancing the structure, SEO, and presentation of your web pages.
This guide will delve into the intricacies of the HTML <meta> tag and how it can be effectively utilized by beginners and experienced developers alike.
Head metadata.
Void element.
UTF-8 encoding.
Description, robots.
Mobile scaling.
Search snippets.
<meta> Tag?The <meta> tag is an HTML element designed for specifying metadata about a document. Metadata includes information such as character set, viewport settings, page description, and more. This tag is placed within the <head> section of an HTML document.
meta tags are not rendered as visible page content. Browsers, search engines, and social platforms read them to encode text, scale layouts, and describe your page correctly.
You will typically use several meta elements on every page — at minimum charset, viewport, and often a description.
The <meta> tag is a void (self-closing) element and does not require a closing tag. It typically includes attributes to define the type of metadata:
<meta name="description" content="Brief description of the page">meta elements inside <head>, not <body>.<meta charset="UTF-8"> as the first child of head when possible.name + content for document metadata, or charset alone for encoding.meta is void — write <meta ...> without inner content.| Purpose | Code Snippet | Notes |
|---|---|---|
| Character encoding | <meta charset="UTF-8"> | First in head |
| Responsive viewport | <meta name="viewport" content="width=device-width, initial-scale=1.0"> | Mobile layouts |
| Page description | <meta name="description" content="..."> | Search snippets |
| Robots directive | <meta name="robots" content="index, follow"> | Crawler hints |
| Open Graph title | <meta property="og:title" content="..."> | Social sharing |
| Refresh redirect | <meta http-equiv="refresh" content="5;url=/new"> | Use sparingly |
charset vs name vs property| Pattern | Attributes | Typical use |
|---|---|---|
| Encoding | charset="UTF-8" | Text decoding (HTML5 shorthand) |
| Document metadata | name + content | description, viewport, robots, author |
| HTTP header emulation | http-equiv + content | content-type, refresh, cache control |
| Social / Open Graph | property + content | og:title, og:image for link previews |
The <meta> tag uses different attribute combinations depending on the metadata type. These three patterns cover most beginner use cases:
charset EssentialSpecifies the character set used in the document. This is crucial for ensuring proper rendering of text and symbols.
<meta charset="UTF-8">name + content CommonUsed in pairs to define various types of metadata. For example, setting the page description:
<meta name="description" content="...">viewport ResponsiveDefines viewport settings, crucial for responsive web design on phones and tablets.
name="viewport" content="width=device-width, initial-scale=1.0"http-equiv AdvancedSimulates an HTTP response header. Used for content-type, refresh redirects, and cache directives.
http-equiv="refresh" content="5;url=/home"property SocialOpen Graph and similar protocols use property instead of name for link preview metadata.
property="og:title" content="..."content Required*The value paired with name, http-equiv, or property. Not used with charset.
content="width=device-width, initial-scale=1.0"* content is required when using name, http-equiv, or property.
Practice the most common meta patterns beginners use on every real-world page.
Typical meta tags inside head (not visible on the page, but read by browsers and crawlers):
These three meta patterns appear on nearly every production HTML page.
Enhance search engine results by providing a concise and relevant page description:
<meta name="description" content="Explore the world of HTML meta tags and their significance in web development.">Ensure proper scaling on different devices with viewport settings:
<meta name="viewport" content="width=device-width, initial-scale=1.0">Specify the character set to be used in the document:
<meta charset="UTF-8">A general name and content pair for document-level metadata:
<meta name="description" content="A comprehensive guide to HTML meta tags">body content, not only in meta tags.Before rendering body, the browser reads meta tags in head.
charset sets encoding; viewport configures the layout viewport on mobile.
Search engines and social bots read description and og:* meta for listings and previews.
Well-written meta tags help every visitor and crawler understand your page before they see the body content.
Understanding the compatibility of the <meta> tag across different browsers is essential for delivering a consistent user experience. The meta element is supported everywhere:
All browsers support <meta> for charset, viewport, and standard name/content metadata.
Bottom line: Use charset, viewport, and description meta on every HTML page.
Mastering the <meta> tag is fundamental for crafting well-structured and search engine-friendly web pages. By leveraging its attributes effectively, you can enhance the user experience and improve the discoverability of your content.
<meta> tag within the <head> sectiondescription for each page (roughly 150–160 characters)charset as the first element inside headmeta tags in the bodykeywords meta for ranking (largely ignored today)http-equiv="refresh" when a server redirect is possible<meta>Bookmark these before you publish your next page.
Not visible.
PlacementFirst in head.
EncodingMobile scale.
ResponsiveSearch snippet.
SEOKey-value pairs.
AttributesAll browsers.
Compatibilitymeta tag provides machine-readable metadata about an HTML document — encoding, viewport, description, robots directives, and more — inside head.<head>, before body. Place charset as early as possible.name="viewport" content="width=device-width, initial-scale=1.0" tells mobile browsers to match the layout width to the device screen.meta element has full support in Chrome, Firefox, Safari, Edge, Opera, and Internet Explorer.Add charset, viewport, and description meta tags in the Try It editor before you publish.
6 people found this page helpful