<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.
- Code the head element for the head section as the first element in the content of the html element.
- 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. - Include a single, required title element inside the head element.
- Include any other optional head section content, such as <script> tags, <meta/> tags, <link> tags and <style> tags.
- End the head element with a matching </head> closing tag.
- 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 Tag | Content of <head>...</head> Element |
---|---|
<title> required | a 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 |