Summary -

In this topic, we described about the <head> tag along with detailed example.

<head> tag is a container for all Head element. <head> tag is of metadata type. <head> tag contains the required tags or elements that are used to link to the document except HTML images.

<head> tag will be used only once. <head> tag is mandatory in HTML 4.01. <head> tag is optional from HTML5.

It should start immediately after the <html> tag and closed before <body> tag open. <head> tag will act as a second level root after <html> tag.

Syntax -

<head> Head content here </head>

The elements can be coded within the <head> tag are -

TagDescription
<title> defines the title of the document
<base> specifies the base location from where the links to made
<meta> represents HTML document metadata
<style> used to define styles for the HTML document
<link> used to define link between external resource from HTML document
<script> inserting scripts in the HTML document
<noscript> used if scripting is unsupported or disabled

Click on the above respective element or tag to get more detailed information.

HTML 4.01 Example -

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Title of the HTML document</title>
    </head>
    <body>
        <!-- Content of the HTML document -->
        <p> HTML body content here </p>
    </body>
</html>

HTML5 Example -

<!DOCTYPE html>
<html>
	<title>Title of the document</title>
	<body>
        <!-- Content of the HTML document -->
        <p> HTML body content here </p>
	</body>
</html>