The <meta> tag in HTML is used to provide metadata about a web page, which is information that describes the page but is not directly visible to users. Metadata can include details like the character set, author of the document, page description, keywords for SEO, and instructions for browsers.
Common Uses of the <meta> Tag:
- Character Encoding
Defines the character set to be used.
Example:
JavaScript
<meta charset="UTF-8">- Viewport Settings
Helps with responsive design, controlling the layout on mobile devices.
Example:
JavaScript
<meta name="viewport" content="width=device-width, initial-scale=1.0">- Page Description
Provides a brief description of the page, often used by search engines.
Example:
JavaScript
<meta name="description" content="Learn about the HTML meta tag and its uses">- Keywords
Contains keywords relevant to the page, although modern search engines don’t heavily rely on this for ranking.
Example:
JavaScript
<meta name="keywords" content="HTML, meta tag, web development">- Author Information
Specifies the author of the web page.
Example:
JavaScript
<meta name="author" content="John Doe">- Refresh or Redirect
Can be used to refresh or redirect the page after a specific time interval.
Example:
JavaScript
<meta http-equiv="refresh" content="5; url=https://example.com">Important
The <meta> tag is placed within the <head> section of the HTML document. It plays a crucial role in search engine optimization (SEO) and improving the user experience on various devices.
