- Home
- /
- Tutorials
- /
- HTML Tutorial
- /
- HTML <meta> Tag
HTML Tags
HTML <meta> Tag
The meta tag puts information about the page into the head: the character set, the mobile viewport, a description for search results. It shows nothing on the page, and has no closing tag.
Most pages need only three: charset, viewport and description. SEO-related ones are covered in detail in HTML Meta Tags for SEO.
Syntax
html
<meta charset="UTF-8">
<meta name="description" content="This is an example of meta description">
<meta name="viewport" content="width=device-width, initial-scale=1.0">| Attribute | What it does |
|---|---|
| charset | The character encoding. Always UTF-8. |
| name | What kind of information, like description, viewport or author. |
| content | The information itself. |
| http-equiv | Imitates a server header. Mostly used for refresh, which is rarely a good idea. |
| property | Used instead of name by Open Graph tags for social sharing. |
Example
html
<!DOCTYPE html>
<html>
<head>
<title>Meta Tag Example</title>
<meta charset="UTF-8">
<meta name="description" content="This page demonstrates the use of meta tags.">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>Welcome to My Website</h1>
<p>This page uses meta tags to provide metadata for browsers and search engines.</p>
</body>
</html>The page shows only the heading and the paragraph. All the meta tags in the head are invisible, but browsers, search engines and social sites read them.
The three every page needs
A minimal, correct head
html
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="A short summary of this page, about 150 characters.">charsetmakes sure every character, from é to ₹ to emojis, displays correctly. Put it first.viewportmakes the page fit phone screens and is needed for responsive design.descriptionis often shown under your title in Google results.
Browser Support
Chrome | Edge | Firefox | Safari | Opera | IE9+ |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |
Good to know
keywordsis ignored by Google and Bing; you can leave it out.- Do not use
<meta http-equiv="refresh">to redirect pages; use a server redirect instead. - Meta tags only work inside the
<head>.
HTML <meta> Tag exercises
Describe the page
Write the meta tag that gives a page this description: Learn HTML step by step.
Result
Check your answer to see it here.
