Little Web Hut

HTML 4.01 and XHTML 1.0 Reference: <head> Tag

HTML <head> Tag - Document Head Section
Syntax This element uses separate opening and closing tags.
<head>...</head>
Usage The <head> tag is used to contain information about the web page like the title, style sheet info, scripts etc. There are 2 main sections in a web page, the head section and the body section. The head section contains information about the web page and the body section contains the content that will be displayed.

HTML <head> tag example using the <title>, <meta>, and <style> tags in the head section.
<html>

<head>
 <title>HTML Test</title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <style type="text/css">
  .mainsection {color:#990000; text-align:center}
 </style>
</head>

<body>

<p>This text is not contained in a div element.</p>
<div class="mainsection">
 This text is contained in a div element and styled.<br>
 The class attribute is used to identify which style to apply.<br>
 The style is defined in the head section.
</div>

</body>
</html>
Test It HTML Style

XHTML <head> tag example using the <title>, <meta>, and <style> tags in the head section.
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
 <title>HTML Test</title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <style type="text/css">
  .mainsection {color:#990000; text-align:center}
 </style>
</head>

<body>

<p>This text is not contained in a div element.</p>
<div class="mainsection">
 This text is contained in a div element and styled.<br />
 The class attribute is used to identify which style to apply.<br />
 The style is defined in the head section.
</div>

</body>
</html>
Test It XHTML Style

Content Model The <head> element can contain the following tags between its opening and closing tags.Notes:
1. Red tags have been deprecated and are allowed in DTD Transitional and Frameset documents but not Strict documents.

<head> Tag Attribute Summary
Required Tag Specific Core Focus Events Language
  profile id1     dir lang xml:lang1
Notes: 1. XHTML only.

<head> Tag Attributes
Attribute Description
profileThe profile attribute specifies a space separated list of URLs for meta data profiles.
idThe id attribute assigns a unique name to a tag. This allows style sheets or scripts to reference the tag. See id Example

Note: XHTML only.
dirThe dir attribute tells the browser whether the text should be displayed from left-to-right or right-to-left. It does not reverse the direction of the characters, like the <bdo> tag does, but it can help the browser to determine if the text should be aligned on the left side or the right side. See dir Example
langThe lang attribute specifies a language. This attribute can help the browser to correctly display text. This attribute can also be useful for braille translation software, speech synthesizers, dictionary definitions, etc. See lang Example
xml:langThe xml:lang attribute specifies a language for XHTML documents. This attribute can help the browser to correctly display text. This attribute can also be useful for braille translation software, speech synthesizers, dictionary definitions, etc. See xml:lang Example

Note: XHTML only.

HTML <head> Tag Examples
Test It HTML StyleTest It HTML Style<head> tag example using the <title>, <meta>, and <style> tags in the head section.