W3C home > Mailing lists > Public > www-html@w3.org > August 2005

Re: Request for DTD use information

From: Laurens Holst <lholst@students.cs.uu.nl>
Date: Sat, 06 Aug 2005 13:29:55 +0200
Message-ID: <42F49F33.4030701@students.cs.uu.nl>
To: "Cox, Vicki" <VCox@lccc.wy.edu>
Cc: www-html@w3.org

Cox, Vicki wrote:
> I teach Web design at Laramie County Community College in Cheyenne,
> Wyoming, USA. The author of one of my new textbooks states: 
>   All XML documents must begin with a document declaration. Because an
>   XHTML document is XML, the recommendation states that documents start
>   with the following XML declaration as the first line of code: 
>   <?xml version="1.0" ?>
The ‘must’ in this text is incorrect. The XML declaration is optional 
for XML 1.0 (it is required in XML 1.1), provided the document encoding 
is UTF-8 or UTF-16. For other encodings (e.g. ISO 8859-1) it is 
required. This is specified in the following two parts of the XML 

- "Definition: XML documents SHOULD begin with an XML declaration which 
specifies the version of XML being used." [1]

- "In the absence of external character encoding information (such as 
MIME headers), parsed entities which are stored in an encoding other 
than UTF-8 or UTF-16 MUST begin with a text declaration" [2]

> He goes on to say: 
>   You currently should not include this declaration in you Web page
>   code. Older browsers do not understand the declaration and may display
>   it as text on the Web page.
That is not true, I know of no such browser. HTML parsers will simply 
see it as an element they do not recognise.

However, in Internet Explorer 6, any markup before the !DOCTYPE (e.g. a 
comment or an XML declaration) will put the browser into ‘Quirks’ CSS 
mode due to a bug in its mode detection system. As that is usually not 
desirable, most people will choose to leave out the XML declaration.

> This seems wrong to me. I have always taught my students to use the
> above declaration with XML documents and to use one of the following
> DTDs with XHTML:
A DTD declaration is required for XHTML and may not be omitted. In 
addition, an XML declaration SHOULD be specified (but, in practice, it 
is better not to for the abovementioned reason). Both are documented at 
[3] in the XHTML specification.

The explanation of the different DTDs for XHTML that you gave is 
correct, but the DOCTYPEs are incorrect - you are presenting your 
students with the HTML 4.01 DOCTYPEs, while instead you should use the 
XHTML ones, that are also documented in the [3] section, e.g.:

<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

For XHTML 1.0 Strict.

I would recommend you to read the XHTML 1.0 specification, it is only a 
short document, and easy to read, with a lot of important information. 
In particular, sections 3.1.1, 4 and appendix C.


[1] http://www.w3.org/TR/2004/REC-xml-20040204/#sec-prolog-dtd
[2] http://www.w3.org/TR/2004/REC-xml-20040204/#charencoding
[3] http://www.w3.org/TR/xhtml1/#strict

Ushiko-san! Kimi wa doushite, Ushiko-san!!
Laurens Holst, student, university of Utrecht, the Netherlands.
Website: www.grauw.nl. Backbase employee; www.backbase.com.
Received on Saturday, 6 August 2005 11:29:59 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:06:11 UTC