Skip to content

Technique G134:Validating Web pages

Obsolete

This technique relates to 4.1.1: Parsing, which was removed as of WCAG 2.2.

About this Technique

This technique relates to 4.1.1: Parsing (Obsolete and removed) (Sufficient).

This technique applies to any markup languages and many other technologies.

Description

The objective of this technique is to avoid ambiguities in Web pages that often result from code that does not validate against formal specifications. Each technology's mechanism to specify the technology and technology version is used, and the Web page is validated against the formal specification of that technology. If a validator for that technology is available, the developer can use it.

Validation will usually eliminate ambiguities (and more) because an essential step in validation is to check for proper use of that technology's markup (in a markup language) or code (in other technologies). Validation does not necessarily check for full conformance with a specification but it is the best means for automatically checking content against its specification.

Examples

Example 1: Validating HTML

HTML pages include a document type declaration (sometimes referred to as !DOCTYPE statement) and are valid according to the HTML version specified by the document type declaration. The developer can use off-line or online validators (see Resources section) to check the validity of the HTML pages.

Example 2: Validating XML

SVG, SMIL and other XML-based documents reference a Document Type Definition (DTD) or other type of XML schema. The developer can use online or off-line validators (including validation tools built into editors) to check the validity of the XML documents.

Example 3: Batch validation with Ant

The xmlvalidate task of Apache Ant can be used for batch validation of XML files. The following Apache Ant target is a simple example for the validation of files with the extension .xml in the directory dev\\Web (relative to the Ant build file).

<target name="validate-xml"> 
  <xmlvalidate lenient="no"> 
    <fileset dir="dev/web" includes="*.xml" /> 
  </xmlvalidate> 
</target>

Related Resources

No endorsement implied.

Validating HTML

Validating XML

  • XML Validator - A Document Validation Service by JavaView allows you to check wellformedness and validity of XML files, by file upload or by direct input of XML code.
  • Apache Ant's XMLValidate Task can be used to validate XML-based documents. This tool can be used to validate entire directories (and subdirectories) of XML files.
  • XML Schema Validator by Christoph Schneegans is an online tool that allows you to validate XML files by URI, by file upload, by direct input of complete XML documents, and by direct input of XML code fragments. A bookmarklet that allows you to validate the page currently displayed in your browser is also available. This validator claims to be more accurate than the W3C validator.
  • XML Schema Validator by CoreFiling is an online tool that allows you to validate an XML file against a W3C XML Schema, both of which can be uploaded.
  • Schema Validator: this is a validator that allows you to paste XML and W3C XML Schema code into text boxes to validate XML code.

Note that many programming editors, XML editors and integrated development environments (IDEs) can validate XML files. These include the following free and/or open-source tools:

  • the programming editor JEdit with the XML and SideKick plugins, which supports DTDs and W3C XML Schemas,
  • the "workbench" Eclipse with the Web Tools Platform,
  • the XML editor Jaxe, which validates XML files with Apache Xerces,
  • Emacs in nXML mode (see the Emacs documentation wiki),
  • the XML editor Pollo, which supports DTDs, W3C XML Schemas and RELAX NG schemas, and is best suited for tree-like XML files.

Tests

Procedure

For HTML, SGML-based and XML-based technologies:

  1. Load each page or document into a validating parser.
  2. Check that no validation errors are found.

For other technologies:

Follow the validation procedure defined for the technology in use, if any exists.

Expected Results

For HTML, SGML-based and XML-based technologies:

Check #2 is true.

Back to Top