HTML <head> Tag
Example
An HTML document, with a <title> tag inside the head section:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
The content of the document......
</body>
</html>
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The <head>
element is a container for all the head elements.
The <head>
element can include a title for the document, scripts, styles, meta information, and more.
The following elements can go inside the <head>
element:
- <title> (this element is required in an HTML document)
- <style>
- <base>
- <link>
- <meta>
- <script>
- <noscript>
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 (used to specify a default URL and a default 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 (used to add 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 (used to link 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;
}