From the Top: The Head Element

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:

  • profile
  • lang
  • dir

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:

  1. 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.
  2. 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

 

This entry was posted in Markup, Standards. Bookmark the permalink.

2 Responses to From the Top: The Head Element

  1. Jon Henshaw says:

    If a web designer doesn’t include the head element, then that means they’re not including the title element. Search engines, like Google, still use the title element on both search results (which help user know what the page is about) and in their algorithm. Not using it means throwing out an important component to driving traffic to your website.

  2. Gez says:

    If a web designer doesn’t include the head element, then that means they’re not including the title element.

    The author isn’t able to exclude the head element with HTML. It’s there, it’s just the tags are optional. The title attribute is only valid in the head of the document, so providing the title element is used before content for the body (along with other elements that can go in the head like link, script, meta, etc), the head element will contain the title element. See example of a document without head tags. The document contains some scripting to show what’s included in the head and the body (obvisously, requires scripting to be enabled to see the results).