HTML <head> Tag for <title>, <script>s and <link>s

 

ATTENTION: THIS PAGE IS Valid HTML 5 AND IS BEST VIEWED WITH HTML 5 - Please upgrade your browser or download one of the HTML 5 compatible browsers such as Mozilla Firefox, Chrome, Opera or IE 9 (March 14, 2011 or later). For more information see HTML 5 browsers.


If you find this helpful, please click the Google +1 Button to the left, if it is white, to make it turn blue or red. Thank you! (It also helps find this page again more easily.)


PDF mobile

The <head> Tag in HTML 5

The <head> tag creates the head section of the document, which contains the HTML page title that appears in the title bar of the web browser window plus other metadata information describing the document and possibly linking to other related resources. The head element is the first of the two elements making up the inner HTML of the top html element, preceding the <body> start tag for the body section, which is created by the body element in the top html element inner HTML. The <head> tag is one of the structure tags in HTML.


<head> Tag Syntax

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/site-template.xsl"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      ... metadata content ...
      <title>... text content ...</title>
      ...
   </head>
   <body>
      ... flow content ...
   </body>
</html>
Rules for coding the HTML head element

Make sure you understand the difference between a tag and element and are familiar with the definitions of namespace and other HTML terms.

  1. Code the head element for the head section as the first element in the content of the html element.
  2. Begin the head element with a starting <head> tag. The element name uses lower case letters and should be in the HTML namespace, which it will pick up automatically from the xmlns attribute on the <html> tag.
  3. Include a single, required title element inside the head element.
  4. Include any other optional head section content, such as <script> tags, <meta/> tags, <link> tags and <style> tags.
  5. End the head element with a matching </head> closing tag.
  6. After the head element, a body element is the only other non-whitespace content inside the html element.

<head> Tag Content Model

Contents of the <head>...</head> Element

The content of the head element is expected to be metadata content with some restrictions. Therefore, the following metadata elements can be coded between the starting <head> tag and the ending </head> tag:

HTML TagContent of <head>...</head> Element
<title> requireda single required title element with the title that is to appear in the browser's address bar
<base/>an optional base element
<command/>optional command element(s)
<link/>optional link element(s)
<meta/>optional meta element(s)
<noscript>optional noscript element(s)
<script>optional script element(s)
<style>optional style element(s)
<rdf:RDF>optional RDF element(s)
<!--comments-->possibly interspersed with HTML comments

<head> Tag Attributes

Attributes of the <head> tag
global attributes The only attributes that can be coded on the <head> tag are the common HTML attributes.

<head> Tag Examples

Examples of the head tag in HTML 5
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/site-template.xsl"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <link rel="stylesheet" type="application/xslt+xml" href="/site-template.xsl"/>
      <title>Example Only</title>
   </head>
   <body>
      ...
   </body>
</html>

Changes in HTML 5 - <head> Tag

What's new in HTML 5
Differences between HTML 5 and earlier versions of HTML

The <object> tag is not allowed in the head section.

The 2000-2010 Recommendations from the W3C HTML Working Group defined the HTML namespace for the head element type name along with the names of all HTML element types. In older (pre-2000) versions of HTML, element type names were not associated with a namespace.


Valid HTML 5