Overview
The <head> element is a container for all of the head elements. Elements inside <head> can include scripts, instruct the browser where to find style sheets, provide meta information, and more.
The following table lists the tags that can be added to the head section:
| Tag | Description |
|---|---|
| <base /> | Defines a default address or a default target for all links on a page |
| <link /> | Defines the relationship between a document and an external resource |
| <meta /> | Defines metadata about a document |
| <script> | Defines a client-side script |
| <style> | Defines style information for a document |
| <title> | Defines the title of a document |
<base>
The <base> tag specifies a default address or a default target for all links on a page:
<head>
<base href="http://example.com/images/" />
<base target="_blank" />
</head>
<link>
The <link> tag defines the relationship between a document and an external resource.
The <link> tag is most used to link to style sheets:
<head>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<meta>
The <meta> tag provides metadata about the HTML document.
<script>
The <script> tag is used to define a client-side script, such as a JavaScript.
In HTML5, the type attribute is optional as all scripts are assumed to be of type "text/javascript".
<style>
The <style> tag is used to define style information for an HTML document.
Use the the style element to specify how HTML elements should render:
<head>
<style type="text/css">
body {
background-color: white
}
p {
color:blue
}
</style>
</head>
<title>
The <title> tag defines the title of the document.
The title element is required in all HTML/XHTML documents.
The title element:
- defines a title in the browser toolbar
- provides a title for the page when it is added to favorites
- displays a title for the page in search-engine results
A simple HTML document, with the minimum required tags:
<html>
<head>
<title>Document Title</title>
</head>
<body>
Document content...
</body>
</html> 