HTML5: How to define metadata about an HTML document?
Solution :
HTML Code:
<!DOCTYPE html><!-- Declares the document type and version of HTML -->
<html><!-- Begins the HTML document -->
<head><!-- Contains metadata about the document -->
<meta charset="utf-8"><!-- Specifies the character encoding for the document -->
<title>How to define metadata about an HTML document</title><!-- Sets the title of the document -->
<meta name="author" content="w3resource"><!-- Specifies the author of the document -->
<meta name="copyright" content="w3resource.com"><!-- Specifies the copyright -->
<meta name="keywords" content="meta tag, html tutorials, w3resource"><!-- Specifies keywords for search engines -->
<meta name="description" content="html meta tag tutorial"><!-- Specifies a description of the document -->
</head><!-- Ends the head section -->
<body><!-- Contains the content of the document -->
HTML meta element is part of the global structure of an HTML page.
</body><!-- Ends the body section -->
</html><!-- Ends the HTML document -->
Explanation:
- The HTML document begins with a declaration of its type and version (<!DOCTYPE html>).
- The <html> element encloses the entire HTML document.
- The <head> section contains metadata about the document, including character encoding and metadata tags.
- Metadata tags like <meta name="author">, <meta name="copyright">, <meta name="keywords">, and <meta name="description"> are used to provide additional information about the document.
- The <meta> tags define properties such as authorship, copyright, keywords, and a description of the document.
- The <body> section contains the main content of the HTML document.
- In this example, a simple text is provided as the content of the body section.
Live Demo:
See the Pen meta-answer by w3resource (@w3resource) on CodePen.
See the solution in the browser
Supported browser
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics