HTML
HTML introduction
HTML basics
HTML text format 1
HTML text format 2
HTML text format 3
HTML links
HTML images
HTML image maps
HTML forms
Fieldset/legend tags
Email links
HTML labels
HTML tables
HTML frames
HTML backgrounds
HTML colors
HTML color shades
HTML color usage
HTML marquees
HTML fonts
HTML entities
HTML stylesheets
HTML layout
HTML div/span
HTML audio
HTML video
HTML objects
HTML d'load media
HTML meta tags
HTML scripts
HTML declarations
HTML head section
HTML document types
HTML tag rules
HTML things to avoid
URL formatting
Encoding and decoding
HTML use/access
HTML publish work
History of HTML
HTML summary

Programming

Programming intro
Java

Markup

First webpage guide
XHTML

Style & Layout

CSS

Browser scripting

Javascript
VBScript
AJAX

Server scripting

PHP
ASP

Making money online

Make money online

HTML head section

As with everything else, there is much more to a webpage than what you just see. Besides what you see on a webpage, also important is what is going on 'under the hood'.

This lesson focuses on:

The <head> tag

The <head> tag is what actually begins the head section of an HTML document. The head section of an HTML document contains several tags that specify important information about the webpage such as title, keywords and descriptions (for search engines), location of stylesheets, scripts, and more.

Example:

<html> <head> <!-- tags that specify important information about the page here --> </head> <body> <!-- page content here --> </body> </html>

Tags inside the head section

There are several tags that go inside the head section of an HTML document.

The <base> tag

The <base> tag acts as a reference point for all the links on a page. This reference point is specified with the <base> tag's href attribute.

Example:

<base href="http://www.landofcode.com />

NOTE: The <base> tag does not have a closing tag.

Read more about the <base> tag in our HTML universal declarations page.

The <link> tag

The <link> tag defines a relationship between two douments. It is used to define the relationship between the document where it is located and another document.

A common use of the <link> tag is to call an external stylesheet.

Example:

<link rel="stylesheet" type="text/css" href="/css/style.css" />

NOTE: The <link> tag does not have a closing tag.

Read more about the <link> tag and stylesheets in our HTML stylesheets page.

The <meta> tag

The <meta> tag is one of the most important tags in HTML. The <meta> tag is used to describe the page in some way as well as other things such as refreshing a page automatically after a certain amount of time, and preventing webpages from being displayed in another websites frames page. Some of the things that can be described using the <meta> tag include the pages author, the software used to create the page, and a description of the content on the page.

Example:

<meta name="keywords" content="computers, electronics, cameras" />

NOTE: The <meta> tag does not have a closing tag.

Read more about the <meta> tag at our HTML meta tags page.

The <script> tag

The <script> tag is used to place scripts on a webpage. When using the <script> tag, you have to use its type attribute to specify the language the script is written in.

Example:

<script type="text/javascript"> document.write("This is a Javascript script."); </script>

Read more about the <script> tag and using scripts at our at our HTML scripts page.

The <style> tag

The <style> tag is used to declare an internal stylesheet.

The <style> tag specifies the content type of a stylesheet with its type attribute which should be set to "text/css".

Example:

<style type="text/css"> h1 { color: #000080; } </style>

Read more about using the <style> tag and stylesheets at our HTML stylesheets page.

The <title> tag

The <title> tag declares the title for a webpage. The title of a webpage can be seen in the top left corner of the web browser. If you look at the top left corner of your web browser window right now, you will see the title HTML head section, as that is the title of this page.

Example:

<title>Introduction to HTML</title>

Putting innapropriate tags in the head section

The above mentioned tags are the only tags that should go in the head section of an HTML document. If you try to put any other tags in the head section of an HTML document, most browsers will display their content, but this will be semantically incorrect and will result in a page that does not validate with a page validator. This is a bad practice and should be avoided.

Practice

Online code editor
Practical examples
Practical exercises
Step-by-step tutorials

Reference

Terms glossary
Reference material

Rate this site

Rate this site
Visitor comments