Both the start and end tags of the head element are actually optional, user agents will automatically produce these if not present in the code. However, if you are coding with Extensible Hypertext Markup Language (XHTML) you will not pass validation due to an error. For consistency, I always use head tags regardless of the flavour of my markup. In this, the fourth article in my series “From the Top” I will give a quick overview of the head element.
The head element contains information about the document like the title, keywords and other data that is not considered to be document content. User agents don’t generally render the contents of the head element to the viewable window but rather make that content available through other mechanisms. The head element accepts three attributes, namely:
We covered lang and dir last week. The profile attribute takes a Universal Resource Identifier (URI) as its value to specify one or more meta data profiles (separated by white space). User agents use this information in two ways:
- As a globally unique name. User agents may be able to recognise the name without retrieving the profile and perform some activity based on known conventions for that profile.
- As a link. User agents may dereference the URI and perform some activity based on the actual definitions within the profile.
If you view the source of this website you will notice that I use profile="http://gmpg.org/xfn/11". This defines a meta data set that is used by the XHTML Friends Network (XFN) to indicate relationship information in links.
That’s pretty much it for the head element. The tags are optional in HTML but not in XHTML. For consistency, I’ve opted to always use it.
Next in “From the Top”
A double-bill this week, be sure to read the fifth article in the series: “The Title Element”. Next week we will take a look at the inclusion of meta elements in the head section of a web page.
The Complete “From the Top” Series