Notes on XHTML Validation P. Conrad for CISC474, Spring 2006 (0) Quick References: URL for w3C validation site: validator.w3.org Fix for the problems: No Character Encoding Found! Falling back to UTF-8. This document is "tenatively" [valid]... Put a file called .htaccess in the root directory of your web site, containing the following line: AddType 'text/html; charset=ISO-8859-1' html Be sure to do "chmod a+rx .htaccess" after you do that. (1) Why XHTML and not HTML One answer comes from the XHTML spec itself: http://www.w3.org/TR/xhtml1 *********************************************************** XHTML 1.0: The Extensible HyperText Markup Language A Reformulation of HTML 4 in XML 1.0 *********************************************************** * Original purpose of HTML: "exchange of scientific and technical documents" * HTML: an application of SGML (Standard Generalized Markup Language). -- SGML: International Standard ISO 8879 from 1986 -- a "language for describing markup languages" -- "HTML is an example of a language defined in SGML." SGML: -- powerful, useful, stable, extensible... but complex -- HTML simplified SGML by providing: small set of tags for "authoring relatively simple documents" "HTML outgrew its original purpose": "rapid invention of new elements for use within HTML" "plethora of new elements has led to interoperability problems for documents across different platforms." (i.e. different code for different browsers, different kinds of computers) XML: Extensible Markup Language * "power and flexibility of SGML" but less complex XHTML: * a way of doing web documents like in HTML, but while following the rules of XML * New kinds of markup being invented all the time. * New kinds of accessing the Internet are being invented all the time. * In XML, you can add new kinds of markup more easily. * If new kinds of markup are defined according to XML and XHTML standards, they should work consistently in _all_ XML/XHTML compliant user-agents (browsers). * XHTML can be more easily adapted to various ways of accessing the internet. (2) Strictly Conforming Documents (From section 3.1.1 of the spec: ) What is a strictly conforming document? "A Strictly Conforming XHTML Document is an XML document that requires only the facilities described as mandatory in this specification." Translation: They should ALWAYS WORK because they use only MANDATORY features. Criteria for "strictly conforming": 1. The document must follow the rules of XHTML as expressed in one of the three DTDs. (more about this in a moment.) 2. The root element of the document must be html. 3. The root element of the document must contain an xmlns declaration for the XHTML namespace, e.g.: 4. There must be a DOCTYPE declaration in the document prior to the root element, and it has to be one of these three: 5. The DTD subset must not be used to override any parameter entities in the DTD. (Prof. Conrad says: I have no idea what this last one means, but I'll try to find out) An additional thing is strongly encouraged by the spec, though in practice, it is probably better to omit it: "An XML declaration is not required in all XML documents; however XHTML document authors are strongly encouraged to use XML declarations in all their documents." That means you put the following on line one: "Such a declaration is required when the character encoding of the document is other than the default UTF-8 or UTF-16 and no encoding was determined by a higher-level protocol." What that means in practice is that if you are using a character set for some language other than English (e.g. an Asian language), the XML declaration is needed to say what the "encoding" of the document is... i.e. how to convert the bits (binary 1s and 0s) into characters that the browser can understand. Note that the xml declaration can cause some versions of Internet Explorer to refuse to render the XHTML document as a web page. So it may be better to leave that off. The better way to get the proper encoding is probably by configuration of the web server; see the item above about the .htaccess file for info on how to do that. Example of a conforming document: A conforming document

This is not a very exiting page, but it will validate as XHTML 1.0 Strict. Try it!

An XHTML 1.1 example: A conforming document

This is not a very exiting page, but it will validate. Try it!