HTML Head
Examples
The title of a document
The title information inside a head element is not displayed in the browser
window.
<html>
<head>
<title>The title is not displayed</title>
</head>
<body>
<p>This text is displayed</p>
</body>
</html>
One target for all links
This example demonstrates how to use the base tag to let all the links on a page
open in a new window.
html>
<head>
<base target="_blank">
</head>
<body>
<p>
<a href="../index.html"
target="_blank">This link</a>
will load in a new window because the target attribute is set to "_blank".
</p>
<p>
<a href="../index.html">
This link</a>
will also load in a new window even without a target attribute.
</p>
</body>
</html>
The Head Element
The head element contains general information, also called meta-information, about
a document. Meta means "information about".
You can say that meta-data means information about data, or meta-information means information about information.
Information Inside the Head Element
The elements inside the head element should not be displayed by a browser.
According to
the HTML standard, only a few tags are legal inside the head
section. These are: <base>, <link>, <meta>, <title>, <style>,
and <script>.
Look at the following illegal construct:
<head>
<p>This is some text you type </p>
</head> |
In this case the browser has two options:
- Display the text because it is inside a paragraph element
- Hide the text because it is inside a head element
If you put an HTML element like <h1> or <p> inside a head element
like this, most browsers will display it, even if it is illegal.
Should browsers forgive you for errors like this? We don't think so. Others
do.
Head Tags
Tag |
Description |
<head> |
Defines information about the document |
<title> |
Defines the document title |
<base> |
Defines a base URL for all the links on a page |
<link> |
Defines a resource reference |
<meta> |
Defines meta information |
Tag |
Description |
<!DOCTYPE> |
Defines the document type. This tag goes before the <html> start tag. |
|