by Alexander Dawson
As web designers and developers, we pay so much attention to what’s directly on the screen (or in our code) that the
<head> of a document and what’s inside is often considered as an afterthought.
While in many cases it’s true that what appears on the screen is the most important part of a website (the content is what people visit a site for), the «thinking code» inside the
<head> of our documents plays an important role.
This article will examine exactly what can fit inside a website’s head.
Mastering the Mind
The head of an HTML document is a busy area, and while it may not have the range of elements that the
<body> can flex, it can actually engineer a range of its own elements to play vital roles in how a site will operate or how it can interoperate with other sites.
Depending on the website, there might be plenty going on inside its head.
So what are your options and how can they benefit your website? Well there’s quite a lot actually!
There are ways to add useful metadata into your documents (for search engines and other web robots to find), icons that you can supply web browsers for extra visuals (like favicons or device-specific icons for the iPad/iPhone), ways to allow the syndication of your content, and even stylistic and behavioral references that include external stylesheets and scripts.
In essence, the
<head> of our HTML documents give the markup below it extra meaning.
Thinking code has many purposes, and not all of it is regulated by an official W3C specification!
Head Elements Gone Rogue
One thing that is unique to the head of our HTML is that it’s adoption and usefulness is determined on convention and popularity. Metadata, for example, relies on search engines and social networks to acknowledge and use the data, and link references require browsers to take advantage of them. Some things that can be included inside the head of our documents aren’t even officially supported by W3C specifications — such as
<meta name="Googlebot"> that is a proprietary meta tag for Google’s spiders — but because of the nature of the elements, they are valid markup.
The first elements we should talk about are those which are independent in the sense that they just serve a single purpose.
One of these elements is so mission-critical that you are required by HTML standards to include it: the
Below are five of the seven (excluding meta and link, since we will talk about them later) head elements:
||This tag describes your document in the browser’s title bar.|
||This tag embeds CSS inside the document.|
||This tag states the base directory of files (for relative links).|
||This tag can be used in the HTML head; typically it is used inside the
<title>Six Revisions - Web Development and Design Information</title>
A document’s title should be unique on every page and should adequately describe its content.
While having a title in your document is required (if you follow W3C standards), the other tags might be of limited use to you.
For example, external stylesheets (instead of
<style> tags) and an htaccess file (as opposed to
<base>) are better options for declaring CSS style rules and declaring the base directory.
Mighty <meta> Tags
Of all the elements that appear in a document’s head, none is as ubiquitous as
These elements — while being highly desired for search engine optimization– are more of a pseudoscience affair, as the influence they have on search engines aren’t publicly disclosed.
With the exception of the
<meta="http-equiv" content-type=""> that specifies the document’s MIME type, they are all optional.
Getting the page’s encoding correct (through content-type) is important.
IE6 can take advantage of a special http-equiv value called imagetoolbar
Below are some examples of
||Gives you greater control over browser caching.|
||States the MIME type for layout engines.|
||Dictates the primary spoken/written language used in the document.|
||States the expiration date of the document.|
||Forces IE6 to either disable or enable the image toolbar on hover.|
||Allows you to specify when the document was last modified.|
||Disables (or restores) the default theme for form components in Microsoft Internet Explorer 6 and above.|
||Redirects the page at a specified time (web spiders don’t like this one).|
||Microsoft extension to dictate compatibility mode triggering.|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
http-equiv isn’t the only attribute that can provide useful information. And even though
keywords are presumed to be ignored by Google and
description is only used to represent SERP listings (not acting as a ranking factor), there are no set standards for what values should be used.
Search engines like Google can use a
<meta description=""> in its results.
Read full article…