Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

HTML <head> Tag


Example

A simple HTML document, with a <title> tag inside the head section:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Title of the document</title>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html>
Try it Yourself »

More "Try it Yourself" examples below.


Definition and Usage

The <head> element is a container for metadata (data about data) and is placed between the <html> tag and the <body> tag.

Metadata is data about the HTML document. Metadata is not displayed.

Metadata typically define the document title, character set, styles, scripts, and other meta information.

The following elements can go inside the <head> element:


Browser Support

Element
<head> Yes Yes Yes Yes Yes


Global Attributes

The <head> tag also supports the Global Attributes in HTML.


More Examples

Example

The <base> tag (specifies a default URL and target for all links on a page) goes inside <head>:

<html>
<head>
  <base href="https://www.w3schools.com/" target="_blank">
</head>
<body>

<img src="images/stickman.gif" width="24" height="39" alt="Stickman">
<a href="tags/tag_base.asp">HTML base Tag</a>

</body>
</html>
Try it Yourself »

Example

The <style> tag (adds style information to a page) goes inside <head>:

<html>
<head>
  <style>
    h1 {color:red;}
    p {color:blue;}
  </style>
</head>
<body>

<h1>A heading</h1>
<p>A paragraph.</p>

</body>
</html>
Try it Yourself »

Example

The <link> tag (links to an external style sheet) goes inside <head>:

<html>
<head>
  <link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>

<h1>I am formatted with a linked style sheet</h1>
<p>Me too!</p>

</body>
</html>
Try it Yourself »

Related Pages

HTML tutorial: HTML Head

HTML DOM reference: Head Object


Default CSS Settings

Most browsers will display the <head> element with the following default values:

head {
  display: none;
}


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.