HyperText Markup Language/Head and Body

An HTML file is divided into two basic sections: the head and the body, each demarcated by their respective tags. Thus, the essential structure of an HTML document looks like this :

The HEAD element
All data in the head section of an HTML document is considered "meta-data", meaning "data about data". The information in this section is not normally displayed directly. Instead elements such as  affect the appearance of other elements in the document. Some items in the head section may be used by programs such as search engines to learn more about the page for reference purposes.

The  element should always contain a   element which sets the title commonly displayed by the web browser in the title bar of the window. Here is an example of the use of the  element: There can only be one  in the header section.

There may be any number of the following elements inside the  element:


 * style : Used to embed style rules in a document. In most cases, a consistent look across multiple web pages is desired, so style is specified in a separate stylesheet file, linked using the  element. Thus, style is used in the head when the style applies to this page only.


 * link : Used to link the page to various external files, such as a style sheet or the location of the RSS feed for the page. The type of link is set using the  attribute. The   attribute specifies the MIME type of the document found at the location given by the   attribute. This allows the browser to ignore links to MIME types it does not support. Examples:


 * script : Used to link to an external Javascript file or to embed Javascript in the page. Linking to an external file is the preferred technique in real web pages though many examples embed the script for simplicity.


 * meta : Used to set additional meta-data properties for the HTML document, such as related keywords, etc. Examples:


 * object : Embeds a generic object. This element is not commonly used in the head, but rather in the body section.

There may also be a single  element. This element sets the base URI for resolving relative URIs. It is rarely necessary to use this element.

The TITLE element
The title element contains your document title and identifies its contents in a global context. The title is typically displayed in the title bar at the top of the browser's window. It is also displayed on the bookmark list of the browser. Title is also used to identify your page for search engines. Example: Some Amazing Web Page

The BODY element
Unlike the  element, any plain text placed between the   tags will be displayed on the web page by the browser.

What to avoid. The following example is bad practice: The current standard is HTML5, and,  ,  ,  ,   and   attributes have all been long deprecated. You may find them in older files, but they should not be used now. They have been superseded by the CSS rules given below (using these rules is discussed in a later section HyperText Markup Language/CSS). The values from the previous example have been used as examples in these rules.
 * text :
 * bgcolor :
 * background :
 * link :
 * alink :  (an active link is a link that is being clicked or has the keyboard focus)
 * vlink :
 * hover (not an html attribute) :  ('hover' is the style of a link when the mouse pointer is over it)

HTML/Fondamenti