These are the answers to last week’s Web Developer Quiz. If you have not attempted the quiz yourself, I recommend you do so before reading the following answers. All the responses to the quiz from ealier this week were made public earlier today.
Validation
There is only one error within the sample document, validate it and see for yourself:
Line 4, column 11: there is no attribute “ALIGN”
The align attribute is not valid in HTML 4.01 Strict because it is deprecated. It is valid in HTML 4.01 Transitional. For information about why line 7 isn’t an error, refer to the validation quiz and associated answers I published earlier.
Elements in the DOM
There are 3 p elements within the document. The syntax: <>
in
an empty start-tag, an unsupported SHORTTAG
feature from SGML. It basically
means to open the most recent unclosed element. Similarly, </>
is
an empty end-tag which ends the most recent open element.
The em
element will not be present because, despite appearances to the contrary,
it is actually commented out. The head
and body
elements will still be present,
even though their start- and end-tags have been omitted.
Validate it and look at the Parse Tree to confirm these answers.
Semantics
The unordered list (option 3) is the most semantically correct. A stylesheet may be used to style it in any way desired.
The <h1>
element without the style
attribute or the class
attribute
with a presentational class name is the most appropriate markup for a document
title. An external stylesheet may be used, and is the recommended way, to horizontally
centre it in a visual medium using a large, bold font. The use of the style
attribute or the presentational class name is not recommended because it fails
to separate the markup from the presentation.
Everyone got these 2 questions correct. Well done. In hindsight, I wish I had made these more difficult, but since semantics is not an exact science, I found that (in general) the more complicated the question, the less specific the answer could be. So, I settled for relatively easy questions for things that beginners tend to markup poorly.
Character References
- For an HTML 4.01 document: the numeric character reference:
’
and the character entity reference:'
are invalid. - For an XHTML 1.0 document: technically, none of them are invalid; however
the numeric character reference:
’
, while it is not prohibited in XML, refers to a Unicode control character and should not be used anyway. - For a generic XML document with no DTD, only the character entity reference:
’
is invalid.'
is valid because it is one of the 5 predefined entities in XML.
Since few people correctly answered these questions, I will be providing more information about this in tomorrow’s post.
Media Types (MIME)
An XHTML 1.1 document SHOULD NOT be served with the text/html
MIME type. See the XHTML
Media Types Note for more information.
An XHTML 1.0 document MAY be served as text/html
when
the document conforms to the Appendix
C HTML Compatibility Guidelines in the
XHTML 1.0 Recommendation. Those who pointed out that this is ludicrous get
a bonus point.
If any of you have any questions or comments regarding this quiz, please feel free to let me know. The feedback I have recieved, or will recieve, regarding this quiz will help me a lot with the next one I’m planning, which will most likely be a CSS quiz of some kind, possibly followed by a JavaScript/DOM quiz if I have time. Beyond that, well, you’ll have to wait and see.