DTDs and syntax

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
If DTDs are supposed to enforce syntax rules, then why if I have the
following DTD the html underneath works?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd ">

<b><i>italics bold</b></i>
<img src="images/bacon.jpg">

The first line should be
             <b><i>italics bold</i></b>
The second line should be
            <img src="images/bacon.jpg" />

Shouldn't I get an error message or the code just won't work?

Re: DTDs and syntax

Quoted text here. Click to load it

Works? Where?

If you mean that it works your favorite browser, that's because it
doesn't handle DOCTYPE declarations (the way it's supposed to).

David Hsther

Re: DTDs and syntax

On 30/05/2005 20:56, JimO wrote:

Quoted text here. Click to load it

The language - XML in this case - specifies the syntax rules. The DTD
defines what elements are permitted in the document, and how they should
(or should not) be used to structure the document. Neither enforce any

Quoted text here. Click to load it


Quoted text here. Click to load it

If you're serving this as application/xhtml+xml and the user agent is a
'conforming user agent' (in the specification sense), then as I
understand it, the software should flag that as syntax error and stop
parsing. If it's also a validating parser (and it gets far enough into
the document), it should notify you that the markup is invalid.

If those conditions aren't true, the actions taken by a user agent are
implementation dependent.


Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.

Re: DTDs and syntax

Quoted text here. Click to load it

You seem to be throwing your question into more or less randomly chosen
newsgroups - I just answered it in alt.html.dhtml. Apparently you don't
want to get useful answers. Probably you should read a primer on HTML
before proceeding further. Oh, and please do not fix your forged From
field before you have a clue.

Yucca, http://www.cs.tut.fi/~jkorpela /
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Site Timeline