HTML Basic Page Structure

When creating a web page in HTML5, the most recent version of HTML, the basic structure looks as follows:

<!DOCTYPE html>

<html>

<head>

</head>

<body>

</body>

</html>

The 'DOCTYPE', or document type must always be declared first in any web page. This tells the web browser what version of HTML the web page is written in. The above example is the document type declaration for HTML5.

Following the document type, the entire web page is contained in opening and closing HTML tags. The majority of tags in HTML5 come in pairs, one to open and another to close, however, there are exceptions to this. Incorporated into the opening HTML tag, the page's primary language can be specified, so, for example, to specify English as the primary language, the opening HTML tag would look like this.

<html lang="en">

The head section contains items that describe the document, for example, a title for the web page. A title can be added as follows.

<title>Example Page Title</title>

This title is displayed on the tab, in a browser that allows multiple tabs, or in the title bar of the browser.

Other items that can be included in the head section include, page styles, JavaScript, meta information and links to other documents, such as style sheets and JavaScript files. These are discussed in more detail in the section on meta data.

The Body section contains all the elements that are displayed on a web page, that a user sees when they view it in a web browser. These will be discussed in the following sections.

A further tag, which can be used in any part of a web page, is the comment tag. This isn't visible to the user through their browser, but it can be used to, for example, describe how or why something is done in a particular way, so that any one returning to the page to make alterations knows what is going on.

<!-- Comment -->