2002-08-18 23:23 UTC Valid garbage in, valid garbage out: Answers
The correct answers to the quiz I posted just over 2 days ago (find the four markup errors in a document which the automated W3C validator validates) are, in document order:
The language code
englishis not a valid 2 letter language code per RFC 1766. A more correct language code would be
This is the error that I think advanced HTML-specific validators should be able to catch. (As opposed to SGML and XML validators, which is what the W3C validator is.) None of the other errors could be caught by an automated tool until we make huge leaps in AI.
<title>element doesn't contain a title. The contents of the title element would have been more appropriate as
<meta name="author" content="Ian Hickson">or some such (maybe using Dublin Core semantics). A correct title would have been "Current weather in Berlin, Germany" (same as the H1).
<cite>element in the H1 is grossly inappropriate. The
<em>element would be better, if the intent was to emphasise the name of the city or the site of the weather. If the
<cite>element was to be used at all, it should have been to give the source of the weather information (namely, CNN Weather).
The alternate text for the icon ("low wind icon") is not alternative text, it's descriptive text. The text given would have been better in a
titleattribute. Correct alternative text would be something along the lines of "The wind is low.", which would have conveyed exactly what the icon was supposed to convey. Note that simply "low wind" would be suboptimal alternate text (although certainly more correct than "low wind icon"), as it would not have blended in well with the test of the paragraph.
I received a few incorrect answers, and to satisfy everyone's curiosity, I'll explain why they were wrong:
- "C" is an ABBR and should be marked up as such.
Not all abbreviations need be marked up, in fact I would recommend only marking those that are likely to be unfamiliar to readers, otherwise UAs that highlight or expand abbreviations and acronyms will make your page annoying to read.
- Missing HEAD and BODY elements or HTML and P end tags.
Actually, all of these are optional in HTML. (If they weren't, this would be the kind of error a validator would have caught, anyway.)
If you look in the HTML DTD or in the element index, you'll see that HTML, HEAD and BODY are marked as having optional start and end tags — that's what O means. For example:
<!ELEMENT BODY O O (%block;|SCRIPT)+ +(INS|DEL) -- document body -->
Similarly, the P element has optional end tags (the first dash means the start tag is not optional):
<!ELEMENT P - O (%inline;)* -- paragraph -->
SGML processors (HTML is an SGML language like XHTML is an XML language) are able to unambiguously determine where implied start and end tags would appear. Note that this is a rather confusing feature of SGML (although by far not the most confusing one) and so XML doesn't have it... don't go omitting start and end tags in XHTML documents, they are not optional there!
- The IMG shouldn't be in a P.
Why not? If you substitute the image for its equivalent alternate text, you'll see that in fact it makes perfect sense for it to be there.
- The DTD doesn't include a URI.
In SGML, the URI (actually, the "system identifier") is optional. The bit before it (the "public identifer") is expected to be mapped to the URI by the application through the use of a "catalog".
Again, XML changed this, so in XHTML, you have to give both. Note that this kind of error, if it had been an error, would have been caught by the validator, anyway.
- The CITE element cannot be in an H1 element.
Actually, it can: CITE is part of
%phrase;which is part of
%inline;and the content model for H1 is
%inline;, as per the DTD:
<!ENTITY % phrase "EM | STRONG | DFN | CODE | SAMP | KBD | VAR | CITE | ABBR | ACRONYM" > <!ENTITY % inline "#PCDATA | %fontstyle; | %phrase; | %special; | %formctrl;"> <!ENTITY % heading "H1|H2|H3|H4|H5|H6"> <!ELEMENT (%heading;) - - (%inline;)* -- heading -->
Again, if this was not allowed, the validator would have mentioned it, since that would be a simple thing that the DTD could explicitly call out.
- The value of the alt attribute is incorrect because it doesn't describe it's contents, "Cloud and wind-blown tree" would be better.
"Cloud and wind-blown tree" would be reasonable
titletext, and a good start on
longdesctext, but it would be terrible alternate text.
What information is the icon conveying? If you were reading out the document, would you say:
Title: Current weather in Berlin, Germany.
There are thunderstorms in Berlin at the moment. The air is very humid. The temperature is a warm 24°C. Cloud and wind-blown tree.
Or would you read:
Title: Current weather in Berlin, Germany.
There are thunderstorms in Berlin at the moment. The air is very humid. The temperature is a warm 24°C. The wind is low.
I'd hope you'd read it like the second. And that tells you immediately what the alternate text should be.
- The BR tag would be better than the P tag in this case.
The BR tag should almost never be used. (Indeed, it is deprecated in XHTML2.) In this case, the P element is correct, since it marks a paragraph.
Below are the scores for those of you who replied by e-mail (sorry, but I'm not logging IRC at the moment, so those that I forgot about aren't on this list — mail me to remind me of your scores, if you care). If people submitted multiple attempts, I've used the best attempt, and mentioned what the original attempt scored. Within each category, the names are listed roughly in the order I received the answers. Congratulations to those of you who got 4 out of 4!
- 4 out of 4
- David Baron
- Chris Hubick
- Simon Willson
- Jonas Jørgensen
- Matthew Wilson
- Markus Niederlechner
- Mauricio de Lemos Rodrigues Collares Neto (originally 2 out of 4)
- Charles Miller
- Matthew Thomas
- Christian Biesinger (originally 3 out of 4)
- Alexey Chernyak (originally 1 out of 4)
- Tom Pike (originally 1 out of 4)
- Michael Lefevre (originally 3 out of 4)
- 3 out of 4
- Bill Mason
- Josh Soref (originally 0 out of 4)
- Jason Fleshman
- Bradley Baetz
- Andy Allan
- Jeff Williams
- 2 out of 4
- Micah Sittig
- David Illsley
- Tim Watt (originally 1 out of 4)
- 1 out of 4
- Devon Y
- Philip Waring (originally 0 out of 4)
A few final notes, since this entry is going to be huge now whatever I do, and I haven't yet used the
<ul> element today:
Lots of people (including many of those who got 4 out of 4) told me it took them several minutes or even hours to answer the quiz. Of course on the other side of the scale, we have David Baron, who answered the quiz even before I posted about it.
No two e-mails used the same subject line.
None of the e-mails used the subject line of the original post on www-style.
Jason Kersey was the only person to spot the "deliberate" markup error in the entry announcing the quiz, and yet he scored 0 out of 4.