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

Re: Request for DTD use information

From: Jasper Bryant-Greene <jasper@bryant-greene.name>
Date: Sat, 06 Aug 2005 21:33:41 +1200
Message-ID: <42F483F5.1090000@bryant-greene.name>
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" ?>

That's wrong. XML documents need only begin with an <?xml ... ?> 
declaration if they use a character set other than the default UTF-8 or 
UTF-16, or if they need to specify additional properties in the 
declaration (like version="1.1" or standalone="yes" etc).

> 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.
> 
> 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: 
>[snip]

XHTML documents *are* XML documents. You may include both the <?xml ... 
?> declaration and the XHTML doctype if you need to. The <?xml ... ?> 
one is unnecessary except where I explained above, though.

However, you should always include the relevant doctype, after the <?xml 
... ?> declaration (if present). By the way, the doctypes you quoted are 
for HTML 4.01, not XHTML. The correct ones are in the relevant XHTML 
specification.

It's true that <?xml ... ?> declarations can confuse older browsers.

> Many thanks, 
> 
> Vicki Cox
> Internet Technology Program 
> Laramie County Community College
> Cheyenne, WY 82007
> vcox@lccc.wy.edu
> (307) 778-4354

Jasper
Received on Saturday, 6 August 2005 09:30:51 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:16:04 GMT