HTML Tutorial

HTML Tag: <head>

Purpose:

The <head> tag is a container for metadata about the HTML document. It provides information about the page's title, character encoding, and other technical details essential for browsers and search engines to interpret the page correctly.

Usage:

  1. Open the <head> tag as the first element within the <html> tag.
  2. Insert metadata elements, such as:
    • <title> for the page title
    • <meta> for character encoding, author, description, keywords, etc.
    • <link> for CSS stylesheets
    • <script> for JavaScript code
  3. Close the <head> tag before the <body> tag.

Attributes:

The <head> tag supports the following attribute:

  • profile: Specifies the URI of a resource describing the document's metadata profile.

Examples:

<head>
  <title>My Website</title>
  <meta charset="UTF-8" />
  <meta name="author" content="John Doe" />
  <link rel="stylesheet" href="style.css" />
  <script src="script.js"></script>
</head>

Exploring the <head> Tag:

  1. Open an HTML editor or text editor.
  2. Create a new HTML document and add the following code:
<!DOCTYPE html>
<html>
  <head>
    <title>Exploring the Head Tag</title>
  </head>
  <body>
    <h1>Welcome to my Website</h1>
  </body>
</html>
  1. Save the file and open it in a web browser.
  2. Right-click on the page and select "View Page Source."
  3. Locate the <head> section to see the metadata information for the page.