Re: Request for DTD use information

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 UTC