Defining an HTML document


XHTML Reference

go to next section 

 

The XML Declaration

The XML declaration is optional with XHTML documents:
<?xml version="1.0" encoding="UTF-8"?>
If present the line appears first in the document and is followed by the DOCTYPE statement.

go to top

 

The DOCTYPE Statement

This statement is mandatory if you intend using a validator to check the correctness of your markup. It is used to identify the particular HTML standard being used for the markup and the language used within the document.

XHTML 1.0 Standard

XHTML is case sensitive so all declarations should be exactly as shown.

If the document is coded in English using strict XHTML 1.0 with style sheets instead of presentation attributes (eg <FONT>, BGCOLOR=) then the following statement should be used:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

If the document is coded in English using XHTML 1.0 older style presentation attributes (eg <FONT>, BGCOLOR=) instead of or as well as style sheets then the following statement should be used:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

If the document is coded in English using HTML 4.0 and frames then the following statement should be used:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

If the document is not English then the appropriate language code should be substituted for 'EN' in the declaration.

Superseded HTML standards

These definitions are included here so that you can recognise which particular standard is used by pages that reference them. Earlier versions of HTML are not case sensitive.

If the document is coded in English using strict HTML 4.01 with style sheets instead of presentation attributes (eg <FONT>, BGCOLOR=) then the following statement should be used:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

If the document is coded in English using HTML 4.01 older style presentation attributes (eg <FONT>, BGCOLOR=) instead of or as well as style sheets then the following statement should be used:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">

If the document is coded in English using HTML 4.01 and frames then the following statement should be used:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd">

If the document is coded in English using strict HTML 4.0 with style sheets instead of presentation attributes (eg <FONT>, BGCOLOR=) then the following statement should be used:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">

If the document is coded in English using HTML 4.0 older style presentation attributes (eg <FONT>, BGCOLOR=) instead of or as well as style sheets then the following statement should be used:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">

If the document is coded in English using HTML 4.0 and frames then the following statement should be used:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN"
"http://www.w3.org/TR/REC-html40/frameset.dtd">

If the document is coded in English using HTML 3.2 then the following statement should be used:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

If the document is coded in English using HTML 2.0 then the following statement should be used:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

go to top

 

The HTML statement

The HTML code within a document must all be enclosed within the following pair of tags: <html xmlns="http://www.w3.org/1999/xhtml"> and </html>. The only exception to this is the XML and DOCTYPE declarations which come before the html open tag.

The following optional attributes can be specified on a <head> tag:

go to top

 

The rest of the Document

Within an HTML document there will be two or possibly three sections. The first section is always the head block where you describe what your document is about.

If you are NOT using frames then the actual document text and graphics will be contained within the body section of the document which is surrounded by <body> and </body> tags.

The following optional attributes can be specified on a <body> tag:

The following attributes are deprecated but can still be used with the transitional DOCTYPE

If you are using frames then the second section of your document will define the initial frame pages to be displayed. These will be surrounded by <frameset> and </frameset> tags. Your will also need a third section to contain what should be displayed if the browser does not support frames. This section will be preceded by these tags <noframes> <body> and followed by these </body> </noframes>. Refer to the frames section for more details.

go to next section 

 

This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow
Donate