X11c: How to Do XHTML Right
Review Questions and Answers
Objectives
----------
A. Identify the rules for a valid, well-formed XHTML document
B. Validate your document using a web-based validator to check
for poorly formed markup
Questions
---------
1. What is meant by saying an XHTML document is "well-formed"?
2. What is meant by saying an XML document is "valid"?
3. How (if at all) can an XHTML document be "well-formed" but
not "valid"?
4. How (if at all) can an XHTML document be "valid" but not
"well-formed"?
5. What are the three parts of a well-formed XML document?
6. What is the purpose of the Prolog of a well-formed XML
document?
7. What is the content of the Prolog of a well-formed XML
document?
8. What is the purpose and content of the "Root Element" of an
XML document?
9. What is meant by calling an element "the root" element?
10. What are the three rules that summarize well-formedness?
11. What are the two main types of XML elements?
12. What does an XML element's tag consist of?
12. What does an "empty" XML element consist of?
13. What does a non-empty (normal) XML element consist of?
Answers
-------
1. Following the rules of XML corresponds closely to what
is meant by making a document well-formed. [X11cA1s]
2. Following the rules specific to the XML-based
language is what generally makes a document valid. A
document is valid when all the elements (tags) conform to
the XML-based definition. [X11cA2s]
3. Web pages can be well-formed but not valid, if they have
appropriate XML structure, but don't follow the proper XHTML
rules. [X11cA3s]
4. Web pages can not be valid if they are not also
well-formed. [X11cA4s]
5. Prolog, Element, and optional Miscellaneous
6. Prolog's purpose is to give information about the
type of document this is.
7. Prolog contains an XML declaration and a document
type declaration.
8. The Root Element is the container of the document's
primary content.
9. The "root" is the starting place, the element that is
not contained in any other element, and which contains all
the other elements of the document.
10. All non-empty elements must have start and end tags.
All empty elements must be self-identifying with /> at the
end.
All elements must be nested properly: First-In Last-Out.
11. Empty and non-empty (normal) elements.
12. An XML tag is made up of the following:
An opening angle-bracket "<"
The name of an element defined for the XML-based language
(such as XHTML)
Any attributes required or allowed for that particular
element, separated by spaces
A closing angle-bracket ">"
12. A "self-closing" tag, with slash "/" immediately
preceding the closing angle-bracket ">"; there is no
closing tag.
13. A normal XML element consists of:
an opening tag
text contents, possibly including nested elements
a closing tag, having a "/" immediately after the "<" and
no attributes