XHTML - Validate documents

  »   XHTML  »   XHTML Tutorial - Validate documents

How to validate the XHTML documents

To validate an XHTML document you must add to the beginning of the document the DOCTYPE declaration according to the document type you need (Strict, Transitional or Frameset).

XHTML!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";

Once the DOCTYPE tag was added, you need to check that all contained tags have the corresponding structure according to the rules explained in the previous tutorials.

To validate your code and easily find mistakes you can use the W3C XHTML Validator at validator.w3.org.

If you need to change a big number of similar tags, you can use search and replace tool available in moast text editors. For example:


Replace "TABLE" with "table" and you will obtain a valid XHTML tag:


It is also important to remember to self close the image and break line tags. You can do that by adding <img......... /> and <br />. Notice the space before the slash.

If you have any suggestions about how to run a faster transformations of HTML documents to valid XHTML code, feel free to leave it in a comment