HTML | <head> Tag

The <head> tag in HTML is used to define the head portion of the document which contains information related to the document.
The <head> tag contains other head elements such as <title>, <meta>, <link>, <style> <link> etc.
In HTML 4.01 the <head> element was mandatory but in HTML5, the <head> element can be omitted.

Tag Specific Attributes:

The below-mentioned layout-attributes of the <hr> tag have been removed from HTML5.
Attribute:



  • profile: It is used to specify the URL to a document which contains one or more meta data profiles for browsers to clearly understand the information.

Syntax :

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

Below program illustrates the <head> element:

Input:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html lang="en">
  
<head>
    <title>HTML Head Tag </title>
</head>
  
<body>
    <p>GeeksforGeeks is a portal for geeks.</p>
    <hr>
</body>
  
</html>

chevron_right


Output:

2. Using style tag inside head tag.
Input:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


Output:

3. Using link tag inside head tag.
Input:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


Output:

Supported Browser: The browser supported by <head> tag are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


My Personal Notes arrow_drop_up

I am a technology enthusiast who has a keen interest in programming I am pursuing Engineering in Computer Science from GEU, Dehradun I like to unwind by watching movies and English sitcomsI have a keen interest in music

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.