Re: need help with an explanation

by KeithWBell(at)aol.com

 Date:  Mon, 19 Jun 2000 07:55:54 EDT
 To:  krhenry(at)sirius.com,
hwg-techniques(at)hwg.org
  todo: View Thread, Original
In a message dated 19/06/00 09:17:31 GMT Daylight Time, krhenry(at)sirius.com 
writes:

> OK, I don't quite know where to start.  I'm hoping that this list can help
>  me come up with an explanation for a potential client of why ,<head>,
>  and  tags are needed.

Kristin, the HTML 4.01 spec says (in Clause 7.1 Introduction to the structure 
of an HTML document):
---------
An HTML 4 document is composed of three parts:

1. a line containing HTML version information,
2. a declarative header section (delimited by the HEAD element),
3. a body, which contains the document's actual content. The body may be 
implemented by the BODY element or the FRAMESET element.

White space (spaces, newlines, tabs, and comments) may appear before or after 
each section. Sections 2 and 3 should be delimited by the HTML element.
---------
The "line containing HTML version information" is the DOCTYPE declaration, 
such as:

<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html40/loose.dtd">

Note that this clause states that sections 2 and 3 (i.e. the HEAD and the 
BODY) SHOULD by delimited by the HTML element. SHOULD (that is, preferable) 
but not MUST (that is, mandatory). The spec shows both the opening and 
closing tags for the HTML element to be optional; similarly with both the 
HEAD and BODY elements.

The example the spec provides of a simple HTML document goes like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">

   <HEAD>
      <TITLE>My first HTML document</TITLE>
   </HEAD>
   
      Hello world!
   


I think what you can draw from that is that it is good or recommended 
practice to use the HTML, HEAD and BODY tags even if not strictly necessary.

Clause 7.4.2 (The TITLE element) states "Every HTML document must have a 
TITLE element in the HEAD section."

This is borne out by validation, regardless of the presence or absence of the 
tags for the HTML, HEAD or BODY elements. For example, this validates with 
the W3C validator:
-----
<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html40/loose.dtd">

<title>This is the page title</title>

This is a test page.
-----

But this does NOT validate:
-----
<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html40/loose.dtd">

This is a test page.
-----

Neither construction uses the tags for HTML, HEAD or BODY; and the only thing 
that distinguishes them is the presence of a TITLE element in the version 
that validates.

Personally, I always use the tags for HTML, HEAD and BODY. The presence of 
the HTML tag allows you to specify the LANG language code attribute, and if 
you aren't using CSS to control things like background colour, text and link 
colours, then you need the BODY tag to specify these with appropriate 
attributes, if you don't want the browser defaults to apply.

Hope this doesn't make matters even more confused!

Regards
Keith Bell

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA