Open In App

HTML <head> Tag

The HTML <head> Tag is used to define the head portion of the document which contains information related to the document. Metadata refers to data about an HTML document. Unlike other content, metadata is not typically displayed on the page itself.

The <head> element is a container for metadata tag and contains other head elements such as:

TagDescription
<title>Defines the title of the document.
<meta>Provides metadata about the HTML document.
<link>Links external resources such as stylesheets.
<style>Defines internal CSS styles.
<link>Connects external resources like stylesheets.
<script>Embeds or links to scripts.
<noscript>Defines content if scripting is not supported.

Note:

Syntax:

<head>
      <title>Title of the document</title>
</head>

Example 1: The below example head containing title. Body holds a paragraph. Basic webpage structure for content presentation.

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>HTML Head Tag</title>
    </head>

    <body>
        <p>
            GeeksforGeeks is a portal for geeks.
        </p>
    </body>
</html>

Output:

Example 2 : The below example illustrates the usage of style tag inside head tag.

<!DOCTYPE html>
<html>
    <head>
        <style>
            body {
                background: skyblue;
            }

            h1 {
                color: red;
            }

            p {
                color: blue;
            }
        </style>
    </head>

    <body>
        <h1>GeeksforGeeks</h1>
        <p>It is a portal for geeks.</p>
    </body>
</html>

Output:

Example 3: The below example illustrates the usage of link tag inside head tag.

<!DOCTYPE html>

<html>
    <head>
        <link
            rel="stylesheet"
            type="text/css"
            href="mystyle.css"
        />
    </head>

    <body>
        <h1>GeeksforGeeks</h1>
        <p>It is a portal for geeks.</p>
    </body>
</html>

Output:

Supported Browsers

Article Tags :