Producing web pages
* HTML CSS DHTML XHTML A to Z of tags        Accessibility          Design

The HTML header

You use the <head> tag to enter information that applies to the whole page. It is not content; the information does not appear in the browser window.

The most important thing in the header is the title of your page. Every page must have a title at the beginning. For example:

<head>
<title>Ann’s idiot guide to creating web pages</title>
</head>

The title starts with the <title> tag and ends with a matching </title> tag.

A browser displays the title at the top of its window and it also appears in the history list and on the list of favourites or bookmarks. Search engines use the title to add a page to their database and use the text in their search results.

Make sure the title makes sense out of context; the title Introduction, for example, isn't helpful because it doesn't tell you anything about what is on the page. Use Introducing HTML instead. I don’t think there is a limit on how long a title can be but keep it shortish (64 characters or less). If you don’t type anything between the <title> tags, the browser usually displays the name of your document as the title.

For a basic page, this is all you need in the header. You can now move on and add the HTML body with the content of your pages. You can enter your headings, paragraphs, lists, tables, pictures and sounds, links to other pages and forms to fill in.

As you learn more about HTML, there are some other important tags that can appear in the <head> tag. They let you do interesting things like:

  • Use style sheets to format your page. I recommend that you use style sheets. You have more control over how pages look and the HTML stays clean and tidy. You can either use the <style> tag to add styles to the page or the <link> tag to refer to a separate file that contains the styles
  • Add scripts to your page. Use the <script> tag to include the script on the page or to refer to a separate file that contains the scripts. The script runs first before the remainder of the page loads
  • Add meta data. Meta data allows you to automatically load pages, specify keywords and a description for search engines to use, enter expiry dates, the author’s name and so on

The other possible tags are <base> and <isindex>. These are described briefly in the A to Z of HTML Tags.