<head> tag

HTML <head> tag

The <head> tag is the head section of the HTML document.

This contains important information such as Title of the HTML document, metadata(information about the data), Link to other documents, Script that is used on the HTML document, Base URL or any External Style-sheet.

It contains metadata. Metadata is like data about data so it shows information about your HTML document.

You should code this tag between the <html> tag and the <body> tag.

The user does not see the information present inside this tag on the front page of the web document.

You should code this tag to improve the visibility of your website in search Engines like Google, Bing, Yahoo etc. This tag contains important tags as below –

  • <title> tag – Shows the title of the Web document. This is visible in the toolbar of the browser.
  • <meta> tag – Metadata is data about the data. This shows the information about the HTML document such as character set, author, keywords, page details, last updated date,  viewport, etc
  • <style> tag – This is an important tag to add style to the website. You can code style properties directly within this tag using Internal CSS.
  • <script> tag – This tag specifies scripts that can run on the client’s browser. This client side script is also called as JavaScript. The script can run from the current document or from an external file as well
  • <noscript> tag – Some Client disables the scripts on their server or their browsers does not support JavaScript. Using this tag, you can display an alternative content to these users
  • <link> tag – This links the current document to other external documents. These external documents can be a CSS file, JavaScript files, etc
  • <base> tag – This sets a base URL for other relative URLs

Syntax:
<head>
  <title>Page Title here</title>
  <base href=”https://www.tutorialbrain.com” target=”_blank”>
  <style> Your style goes here… </style>
  <link rel=”stylesheet” type=”text/css” href=”style.css”>
  <meta charset=”UTF-8″>
  <meta name=”keywords” content=”HTML,CSS”>
  <meta http-equiv=”refresh” content=”45″>
  <meta name=”description” content=”Tutorial for HTML”>
  <meta name=”author” content=”TutorialBrain”>
  <meta name=”viewport” content=”width=device-width,            initial-scale=1.0″ >
  <script> Your JavaScript here… </script>
  <noscript>your browser does not support JavaScript. Please update it.</noscript>
</head>

Example

<head>
  <title> Example of head tag </title>
</head>
<body>
<h1>Give your Heading here</h1>
<p>Give your Paragraph here</p>
</body>

Default CSS Value

display:none;

Difference between HTML4.01, XHTML and HTML5

HTML4 XHTML HTML5
It is must to code the <head> tag. NA <head> tag is not necessary

Attributes used with <head> tag

Attribute Description
profile This sets a URL to an external document which shows the list of meta data rules so that the browser can read them.
(HTML5 does not support this attribute).

Global Attributes

The <head> tag supports Global attributes.

Event Attributes

The <head> tag supports Event attributes.

Supporting Browsers

supporting-browsers for tags

Related Tags

  • <title> tag
  •  <meta> tag 
  • <style> tag
  • <script> tag
  • <noscript> tag
  • <link> tag
  • <base> tag

Tutorials for all brains!