Following yesterday's post about XHTML validation and the script tag (which I assumed to be a browser problem, not a code problem) I got an email from megnut reader Maurice saying,
Script element should always have an end tag and really can't be considered a singular or "empty" type tag like, say, the Image tag or something. I guess it must be a minor glitch in the validator or something.
Since that didn't sound right to me, I decided to go to the source: XHTML 1.0 The Extensible HyperText Markup Language, Section 4.3: For non-empty elements, end tags are required. It says,
4.3. In SGML-based HTML 4 certain elements were permitted to omit the end tag; with the elements that followed implying closure. XML does not allow end tags to be omitted. All elements other than those declared in the DTD as EMPTY must have an end tag. Elements that are declared in the DTD as EMPTY can have an end tag or can use empty element shorthand
So I examine the DTD and see that <script> does not contain EMPTY, which would support Maurice's assertions that the code was in fact, not valid, and there was a glitch in the validator. But then I looked at the definition for <p> and it doesn't contain EMPTY either. But you can use <p /> instead of <p></p>. Or at least, I thought you could. Plus it seems weird since a <script> in reality can be empty, like in my example when it's linked to an external file. So why's the DTD saying it can't be? Anyone actually understand what's going on here?
