Validation Quiz

Let’s say you’ve been writing HTML and XHTML for years. Being a standards activist, you always write well formed, valid markup. You meticulously validate every document you write. Not only that, but you’ve installed the web developer toolbar in Firefox or Mozilla and, as a hobby, you run the validator on every site you visit. With years of experience under your belt, you think you can handle any error the validator throws at you, and you’re confident you can fix whatever it is in under a minute.

If that description fits you, then I hereby challenge you to find the one and only real validation error within the following sample HTML or XHTML document (I’m not telling you which, you figure it out). Do you think the validator will help? Go ahead and test it! I’ve exploited some known bugs in the validator to ensure you can’t cheat quite so easily. The validator will, in its current state, issue 80 errors; none of which are real!

There is one, and only one, true validation error within this document. The first person to comment with the correct answer and explanation will be featured in a follow up post to them give some recognition for their hard work. Feel free to discuss and ask questions here in the comments (or wherever else you like). This is designed to be a fun exercise for you to realise just how much you really don’t know about HTML and/or XHTML.

Do you think you’re ready to take the quiz? Do you think this will be a walk in the park, and you’ll be the first across the line with the right answer? Ok, here it is, and remember, have fun!

Assume the HTTP headers contain: Content-Type: text/html;charset=UTF-8

<?xml version="1.0" comment="Find the Error!" ?>
<!-- -- -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- -- -->
<!doctype html public "-//W3C//DTD HTML 4.01//EN" [
<!ENTITY smile   CDATA "?" -- U+263A WHITE SMILING FACE -->
]>
<html lang="en">
<title/validation quiz/
</head>
<p>In this document, there &exist;s a single validation error.  It makes
use of some <strong<em/very/</strong> uncommon & unsupported markup techiques
designed to fool the faint hearted.
<>This exploits some known bugs in <a href=http://validator.w3.org/
to both help prevent cheaters and confuse even the most experienced
authors.</>
<form method="get" action="http://validator.w3.org/check"
<table
<tr
<td<input text checked id=uri name=uri size=40/>
<><label for=uri>Is this test too hard?</label></>
<><td<button button>Don't Cheat!</>
</tbody
></table>
<ul/
<li><![CDATA[
<li Oops<!-- ?]]> -->
<li>There are < 2 validation errors in this document</li>
<?hello comment="What's this doing here?"?>
<!--- Found the error yet? ---->
<blink>I'll bet this is &#147;annoying&#148;!</blink>
<p align="right">Remeber, it's a Strict DOCTYPE!
<!-- ------ Don't give up now! ----- >
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<p>Is the error here --><li>?/
<p/>The question is: Is this<br>HTML or<br/>XHTML
served as text/html? &smile</></></>

17 thoughts on “Validation Quiz

  1. I believe the problem is on the last line. That should really be inside a block level element. But I’m not 100% sure and don’t really care anymore about SGML now that HTML5 will “obsolete” it. It is a HTML document by the way.

  2. The explanation is that the solidus in text/html closes the paragraph element on line 37, and therefore everything after the solidus and up to the empty end tag must be inside a block level element like Anne said.

  3. David, that’s absolutely correct. I wasn’t expecting this to be solved quite so quickly. Oh well, it should still be a good excercise for people to try and figure out why nothing before that is invalid; at least until I post a full explanation some time next week.

  4. Gidday, L15 C47 (know your name characters in attribute value literals before taking Mr. Clark to task [sigh])

  5. Ah, never mind, I should better know them myself (LCNMCHAR/UCNMCHAR ‘_’ and ‘:’ are not in the default SGML declaration of SP, apparently I commented out the HTML 4 SGML declaration in my catalogue for some reason :-). I can’t be bothered to try the upload form though, when I fix my catalog NSGMLS spots 38:15 as the only error all right.

  6. What I’m interested in, is what this should look like if it were properly rendered. I know that no ‘web browser’ has ever been a conforming SGML parser, and I recognize lots of SGML tricks in there. Odd then that it starts with an XML declaration… Looking forward to the next post.

    BTW you clearly have far too much time on your hands.

  7. The very last line? Missing semi-colon in &smile.

    In SGML, Reference Close (usually “;”) is not required. Non-name characters also terminates the parsing, as does the record end character. In XML, the semicolon is obligatory.

  8. The XML needs application/xml content-type, but this document is text/html.

    What XML? BTW, content-type does not have anything to do with validation.

  9. So do you still insist on SGML-based HTML5 QA tools? I think your post rather nicely demostrates why using SGML tools as a basis for (X)HTML QA tools is not a particularly practical approach.

    (Gotta love the way wrong answers are offered after the right answer has been presented.)

  10. Yes, Henri, I do. It is possible to disable many of the unsupported SHORTTAG features, such as empty start- and end-tags (<> and </>), null end-tags (<foo/.../) and unclosed tags (<foo).

    Considering the only SHORTTAG feature with some (although limited) support in browsers, is minimised attributes and unquoted attribute values, they can be left enabled. See the FEATURES section of the draft HTML5 SGML declaration. With the rest disabled, most of this quiz would infact result in errors, so I see no reason why real SGML tools cannot be used for validation purposes.

Comments are closed.