W3C Validation of XHTML 1.1 Documents


 

To validate an XHTML (or HTML) page, use the *W3C Validator, but bear in mind that Descendant Exclusions also apply.

For XHTML 1.1 served as "application/xhtml+xml" (see Serving XHTML 1.1), the user agent will only be able to parse and display the page if the following well-formedness constraints are obeyed. (If served as "text/html" these constraints still need to be followed but failure to do so won't result in a fatal error.)

  1. The document must have one and only one root element, from which all other elements in the document are descended.
  2. If present, the XML Declaration must occur at the very start of the document, without even any white-space preceding it. Also, the DOCTYPE must occur before the root element. See XML Declaration & DOCTYPE.
  3. Elements must be properly nested.
    Any element which opens with a start tag must be closed with a matching (case-sensitive) end tag and every element must be closed before its parent is closed. For EMPTY elements, the empty-element tag (e.g. <br />) both starts and closes the element in one construct (see Elements with No Content).
  4. Any less-than sign (<) which is not within a CDATA Section, comment or processing instruction must be escaped as &lt; (or numerical equivalent) unless it is being used to begin a tag, comment or other markup.
  5. Any ampersand (&) which is not within a CDATA Section, comment or processing instruction must be escaped as &amp; (or numerical equivalent) unless it is being used to begin a character reference (e.g. &#160;) or entity reference (e.g. &lt;).
  6. Any greater-than sign (>) which occurs in the string ]]> must be escaped as &gt; (or numerical equivalent) unless this string is marking the end of a CDATA Section or is contained within an attribute value, comment or processing instruction. (Note: The string ]]> may never occur within a CDATA Section since it is not possible to escape characters here.)
  7. All entities must have been declared (see Character & Entity References for more information). Some user agents (as recommended in the conditions for *XHTML Family User Agent Conformance) do not treat an undeclared entity as a fatal error but some do and so this point is included in this section.
  8. Attributes must not contain less-than (<) characters (for example, they must not contain comments) - any occurrences must be escaped as &lt; or numerical equivalent.
  9. Attribute values must be quoted either by a pair of double quote (") characters or a pair of single quote (') characters. Any occurrences of the quoting character within the attribute value must be escaped using the appropriate character or entity reference.
  10. An element must not be given more than one attribute with the same name.
  11. The last character of comment text must not be a hyphen (-), i.e. a comment must be terminated by the string --> and not by the string --->.
  12. Text within a comment must not contain the string -- (a double hyphen).

Additionally, in order for a document to be XHTML 1.1 and validate using the *W3C Validator without error or warning:

  1. The XHTML 1.1 DOCTYPE must be specified (see XML Declaration & DOCTYPE).
  2. The root element must be html (all lower-case) with the xmlns attribute specified as the #FIXED value "http://www.w3.org/1999/xhtml".
  3. The content of each element must be as specified in the DTD (see Element Content Models). All element names are case-sensitive and must be specified, for XHTML 1.1, in lower-case only.
  4. The attributes given to each element must be present in the attribute-list declaration for that element type (attribute names are case-sensitive and, for XHTML 1.1, must be written in lower-case).
  5. All #REQUIRED attributes must be present.
  6. All #FIXED attributes, if present, must be given the declared default value.
  7. All attributes which are present must be given values which match the declared native XML 1.0 Type, e.g.
    • Attributes with XML 1.0 Type Enumeration must be assigned a value equal to one of the declared values.
    • Attributes with XML 1.0 Type IDREF must match the id attribute of an element in the document.
    • No two elements may be given the same value for their id attribute.
    and so on ...
    For Attribute Types Defined by XHTML 1.1, the specification should of course be obeyed but any departure from it is unlikely to be noted by the *W3C Validator provided that the rules of the XML 1.0 Type upon which the derived type is based are followed.

Page Footer & Copyright

Copyright © Sally Maughan 2005-2009 (Page last updated on 03 Jun 2009)

*Valid XHTML 1.1 - hosted by *Openstrike

Content based on the W3C Working Draft: *XHTML 1.1 and Recommendation: *XHTML Modularisation 1.1.

W3C, XHTML, XML, HTML, CSS and MathML are *Trademarks of the W3C (*MIT, *ERCIM, *Keio) with which the site's author has no connection.


Up, Next & Previous Links

Your Location

Home > XHTML 1.1 Home > XHTML 1.1 Basics > W3C Validation of XHTML 1.1 Documents