|
|||||||||
|
Structure of documentsThe simple HTML document introduced in the previous section omits a number of HTML tags. If the document was prepared with an authoring tool, the missing tags would probably be supplied automatically and the source would appear as follows:
<!DOCTYPE HTML PUBLIC '-//W3O//DTD WWW HTML 2.0//EN'> <HTML> <HEAD> <TITLE>An English country garden</TITLE> </HEAD> <BODY> <H1>An English country garden</H1> The first line is a DOCTYPE directive and says that this document uses version 2.0 HTML. If this line is omitted, version 2.0 HTML is assumed. The rest of the document is enclosed in an HTML container element (see below); again, this is assumed if it is omitted and is therefore not strictly necessary. Most existing browsers allow you to omit these lines. They are shown here for the sake of completeness. HTML (and SGML) regard a document as a logical hierarchy of elements. Hence, elements are the structural components of a document. Elements start with a tag identifying their type. An element can be a single entity, such as an included image or a special character. These do not require an end tag. Alternatively an element might be a chunk of data or text, which logically requires a terminating tag, in which case the element is referred to as a container. End tags may be omitted if the end tag can be implied by what follows. For example, </P> tags need not occur in a document since they are implied by a <P> tag or in fact by any text; similarly the first <P> tag after a heading can be implied by the presence of text. This means that existing documents will conform to HTML version 2.0 with regard to paragraph marks, even if, looking at the raw HTML, the paragraph tags seem to be strangely placed (often at the end of the last line of the preceding paragraph from the viewpoint of an HTML version 2.0 browser). Originally <P> tags were paragraph separators and terminated a paragraph. They are now being redefined to start paragraphs. This is being done so that attribute information for a paragraph, such as the type of justification, can be included in the leading paragraph tag. This is also how SGML does things, and efforts are under way to make HTML more compatible with SGML. Some start tags may contain attributes, which further define the characteristics of the element. Most attributes are specific to each element type and are described with their related elements below. Attributes usually consist of an attribute name followed by an equals sign and a value. The value may be a string literal enclosed in either single or double quotes or it may be a name token. It is best always to put quote characters around attribute values in a tag.
Next: Naming schemes on Up: The Hypertext Markup Previous: Getting started quickly
Spinning the Web by Andrew Ford |
||||||
Copyright © 1996-2002 Ford & Mason Ltd |