Computer >> Computer tutorials >  >> Programming >> HTML

Why do we use head tag in HTML Page?


The <head> tag is a container for all the head elements in an HTML page. To add a <head>…</head> the tag is quite easy. Add the title of the document under it or meta information, styles, scripts, etc.

Just keep in mind, the <title>…</title> tags gets added inside the <head>…</head> tags.

Why do we use head tag in HTML Page?

Example

You can try to run the following code to add the <head> tag in an HTML page,

<!DOCTYPE html>
<html>
   <head>
      <title>HTML head tag</title>
   </head>
   <body>
      <h2>Working with HTML head tag</h2>
      <p>This is demo text.</p>
      <p>Displaying how head tag is used in HTML. Add title in it or meta information about the document.</p>
   </body>
</html>

Output

Why do we use head tag in HTML Page?