Metadata

HTML metadata provides information about the web page, such as its title, character encoding, and linked resources, typically within the <head> section.

Metadata in HTML

Metadata in HTML provides information about a webpage, such as its description, character set, keywords, and viewport settings. Metadata elements are placed inside the <head> section of an HTML document and help search engines, browsers, and social media platforms understand the page better.

The <meta> Element

  • The <meta> tag is self-closing and does not display content on the page.
  • It provides essential information like character encoding, author, and page description.

Character Encoding (<charset>)

  • Defines the character set for the document.
index.html
<meta charset="UTF-8">

Page Description (description)

  • Helps search engines display a short summary in search results.
index.html
<meta name="description" content="Learn the best HTML metadata practices.">

Keywords for SEO (keywords)

  • Specifies keywords related to the page.
index.html
<meta name="keywords" content="HTML, metadata, SEO, web development">

Author Information (author)

  • Defines the page author.
index.html
<meta name="author" content="John Doe">

Viewport Settings for Mobile (viewport)

  • Ensures responsive design by setting the viewport width and zoom level.

Example:

index.html
<meta name="viewport" content="width=device-width, initial-scale=1.0">

Refresh or Redirect (http-equiv)

  • Automatically refreshes or redirects the page.
index.html
<meta http-equiv="refresh" content="5">

Conclusion

Metadata in HTML enhances webpage functionality, SEO, and responsiveness. Proper use of <meta> tags ensures better search rankings, accessibility, and user experience.