The HTML <head> element contains the page's title and description, and some optional scripts and styles. It is usually placed right after the opening <html> tag and right before the opening <body> tag. <Title> is always inserted first within the head. To apply CSS directly into an HTML document, you must insert the code in the <head> section (or at the very beginning of the <body>) for it to work.
Attributes
HTML 4 attributes
Internationalization attributes lang and dir.
| Attribute | Value | Description |
|---|---|---|
| profile | URL | Specifies some meta data profile location(s), separated by white space. Obsolete in HTML5[1]. |
HTML5 attributes
Usage
To apply this is an HTML document, use:
<html>
<head>
<title>The title</title>
Head content
</head>
<body>
Body content
</body>
</html>
To use internal CSS in the <head> tag, use:
<html>
<head>
<title>The title</title>
<style type="text/css">
h1 {
background-color:black;
color:white;
}
</style>
</head>
<body>
Body content
</body>
</html>
Rendering
The <head> element defines document properties, and is by itself not visible.
Typical CSS representation:
head {
display: none;
}
Coding rules
The <head> element is the first child element of the <html> element. It must contain a <title> element, can contain an <isindex> and an <base> element, and can contain several <script>, <style>, <meta>, <link> and <object> elements.