Introduction
The <meta>
element in HTML is used to provide metadata about the HTML document. Metadata is data about data, which gives information about the HTML document itself rather than the content it contains. Metadata elements are typically placed within the <head>
section of an HTML document.
Here’s how the <meta>
element can be used:
<!DOCTYPE html>
<html>
<head>
<title>Example HTML Document</title>
<meta charset="UTF-8">
<meta name="description" content="This is a sample HTML document">
<meta name="keywords" content="HTML, metadata, sample">
<meta name="author" content="John Doe">
</head>
<body>
<h1>Hello, World!</h1>
<p>This is a sample HTML document.</p>
</body>
</html>
In this example:
- The
<meta>
element with thecharset
attribute specifies the character encoding used in the document. In this case, it’s set to UTF-8, which is a widely used encoding for handling text in different languages. - Other
<meta>
elements provide additional metadata:description
: Provides a brief description of the document.keywords
: Specifies a list of keywords relevant to the document.author
: Identifies the author of the document.
These <meta>
elements are not displayed directly on the webpage but are instead used by browsers, search engines, and other web services for various purposes such as indexing, search engine optimization (SEO), and browser rendering. They help provide contextual information about the document, improve its accessibility, and enhance its discoverability on the web.