Open In App
Related Articles

HTML <head> Tag

Improve Article
Improve
Save Article
Save
Like Article
Like

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 that contains one or more metadata profiles for browsers to clearly understand the information.

Syntax : 

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

Below program illustrates the <head> element:

Program 1:

HTML




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


Output: 
 

Program 2(Using style tag inside head tag)

HTML




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

Program 3(Using link tag inside head tag):

HTML




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

  • Google Chrome 1 and above
  • Edge 12 and above
  • Internet Explorer
  • Firefox 1 and above
  • Opera
  • Safari

 


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 22 Jul, 2022
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials