Re: DTD problem, or validator problem?

* Matthew Wickline wrote:
>This still leaves me curious about why the validator is not giving any
>errors. Take the following document:
>
>
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>    "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
><html>
>    <head><title>test</title></head><body><br /><hr /></body>
></html>
>
>
>As I understand it, the first slash (in the BR) says "I'm putting the
>following inside a BR container" and then we put a greaterthan sign in
>the BR container followed by an HR... but the second slash (in the HR)
>says "I'm putting the following in the HR container" and we put a
>greater than sign in the HR container. Then we close the body and the
>HTML, never closing the HR and the BR.

Take this example:

  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
  <title>test</title>
  <p>...

The <p> closes the implicite head and opens the implicite body since p
doesn't appear in the content model definition of the head element. Same
goes for hr and br, they cannot contain PCDATA so they are closed and
both '>' appear as PCDATA content of the body element in your example.
The document could have been written as

  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
  <html>
      <head><title>test</title></head><body><br>&gt;<hr>&gt;</body>
  </html>

That's just how SGML works...

regards,
-- 
Björn Höhrmann { mailto:bjoern@hoehrmann.de } http://www.bjoernsworld.de
am Badedeich 7 } Telefon: +49(0)4667/981028 { http://bjoern.hoehrmann.de
25899 Dagebüll { PGP Pub. KeyID: 0xA4357E78 } http://www.learn.to/quote/

Received on Thursday, 16 August 2001 17:18:49 UTC