This is a small collection of XHTML tests I have written to test how browsers treat minimal XHTML 1.0 documents.
XHTML 1.0 has an example of a minimal XHTML 1.0 document. Here is that same document with only a few minor title and paragraph content changes: (posted here: Minimal XHTML 1.0 Document)
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Minimal XHTML 1.0 Document</title> </head> <body> <p>This is a minimal <a href="http://www.w3.org/TR/xhtml1/">XHTML 1.0</a> document.</p> </body> </html>
This example cannot work "as-is" with validating processors due to the partial DOCTYPE reference. Or, rather, this example depends upon the server having the XHTML 1.0 Strict DTD (xhtml1-strict.dtd) available in a "DTD" directory which is in the same directory as the document itself. Due to this dependency, this example is less than minimal in this respect, in that it is not self-contained. Here is a self-contained version of this example which points to the W3C XHTML1 Strict DTD: (posted here: Minimal XHTML 1.0 Document with W3C DTD)
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Minimal XHTML 1.0 Document with W3C DTD</title> </head> <body> <p>This is a minimal <a href="http://www.w3.org/TR/xhtml1/">XHTML 1.0</a> document with a W3C url for the DTD.</p> </body> </html>
There are a few valid variants of this example that should also be tested:
<?xml version="1.0" encoding="UTF-8"?>
XML prolog is optional.
This is clear both from the examples in Section 2.8
and also by the fact that production [22] in the grammar, the "prolog", begins "XMLDecl?", where the "?"
means 0 or 1 instances thereof.
text/html
or text/xml
or application/xml
.
It is left quite open ended as to which of those the author should choose.
Hence it makes sense to at least test examples served as "text/html" (.html) and "text/xml" (.xml).
Thus a valid XML document must have a DOCTYPE.[Definition: An XML document is valid if it has an associated document type declaration and if the document complies with the constraints expressed in it.]
Thus a valid XHTML document must have the xmlns attribute with abovementioned value on the root element.The root element of the document must designate the XHTML namespace using the xmlns attribute. The namespace for XHTML is defined to be http://www.w3.org/1999/xhtml.
Here are all four possible combinations of the abovementioned two variants, from "most html-like" to "most xml-like". (The assumption is that the prolog is "closer" to the document than the mime-type and therefore may have greater impact upon how the browser decides to treat the document.)
Try downloading (using the given file names) the above four tests (1-4) to your client machine and viewing them locally in your browser. See if it treats local files differently from those that it receives from the web.
All four test documents are valid XHTML 1.0 strict documents, and therefore should be handled as XHTML - not as plain XML. Each document has little bit of text, and one hyperlink to the XHTML 1.0 specification. The hyperlink should be functional and rendered in the browser's default style for HTML hyperlinks. Here is what each document should have looked like (margins chosen to match popular browser conventions - actual styling may vary):
This is a minimal XHTML 1.0 document without ?xml prolog served as text/html.
This is a minimal XHTML 1.0 document without ?xml prolog served as text/xml.
This is a minimal XHTML 1.0 document with ?xml prolog served as text/html.
This is a minimal XHTML 1.0 document with ?xml prolog served as text/xml.