Forum Moderators: open

Message Too Old, No Replies

The XHTML DOCTYPE tag must be uppercase to validate

...even though XHTML tags must be lowercase

         

Purple Martin

5:01 am on Jun 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I just noticed something odd while using the W3C Markup Validation Service. I was creating a new XHTML page from scratch. I pasted in the doctype, submitted the file to make sure I'd got the basic document structure correct, and sure enough it was valid.

Then it occurred to me that the <!DOCTYPE... tag was in uppercase, and all XHTML tags should be lowercase. So I made it lowercase, resubmitted, and whaddya know it's not valid any more. I changed it back to uppercase and it's valid again.

Seems a bit illogical to me!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body>
<h1>Heading</h1>
</body>
</html>

tombola

7:51 am on Jun 21, 2004 (gmt 0)

10+ Year Member



The DOCTYPE declaration is NOT a html tag.

According to the W3C Recommendation "the root element of the document must be <html>". So, the first html tag in your document is <html>.

encyclo

12:36 pm on Jun 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<!DOCTYPE html PUBLIC

Of course, the html part of the doctype must be lowercase in XHTML, but it is not case-sensitive for HTML doctypes.

choster

2:58 pm on Jun 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not the only quirk, either. DTD is not an XML format, it is EBNS, yet we use it to validate XML documents.

Purple Martin

11:22 pm on Jun 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



All interesting stuff, thanks guys.