XHTML
XHTML introduction
XHTML purpose
XHTML/HTML diff
XHTML syntax
XHTML DTD
HTML to XHTML
XHTML validation
XHTML modules
HTML 5
XHTML history
XHTML summary

Programming

Programming intro
Java

Markup

First webpage guide
HTML

Style & Layout

CSS

Browser scripting

Javascript
VBScript
AJAX

Server scripting

PHP
ASP

Making money online

Make money online

XHTML validation guide

Writing code is one thing, making sure that code is proper is another thing. This process can be quick and easy, long and difficult, or anything in between.

This lesson focuses on:

Why validate?

Validation shows that you have taken the time to write semantic code that follows proper XHTML standards.

XHTML has certain rules and conventions that should be followed if you want your pages to appear as you intend them to appear across browsers. Page validation is the process by which this is verified. Everyone makes mistakes, and it's ok to have a few errors here and there, but whenever this happens and your pages don't validate, you should take the time to fix them.

Document types

Remember to classify your pages into the right category that they belong to.

Transitional document type

If your page uses deprecated features, use the transitional document type.

Example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Transitional document type</title> </head> <body> This is a transitional HTML document </body> </html>

Frameset document type

If your page is built in frames, use the frameset document type.

Example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> <html> <head> <title>Frameset document type</title> </head> <frameset cols="50%, 50%"> <frame src="frame1.html" /> <frame src="frame2.html" /> </frameset> </html>

Strict document type

If your page contains no deprecated features and no frames, use the strict document type.

Example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Strict document type</title> </head> <body> <h1>Content</h1> </body> </html>

For more information on XHTML document types read our XHTML document type definition lesson.

Where and how to validate

You can validate your pages at the free validation service provided by the W3C available at validator.w3.org. This validation service will let you validate either a webpage that is currently online, a local file from your own computer, or by direct input.

Validating a webpage with validator.w3.org

The most common method of validation. You can validate a webpage by inputing the absolute url of the page. The validator will return the results which will included the number of errors and where they occur (if there are any errors). If there are no errors, the validator will tell you that the page was successfully checked and 'passed' the test.

Validating a local file with validator.w3.org

You can validate a local file by uploading that file. Once you upload the file, the validator will return the results which will include the number of errors and where they occur (if there are any errors). If there are no errors, the validator will tell you that the page was successfully checked and 'passed' the test.

Validating by direct input with validator.w3.org

You can validate code by direct input by entering the code in the textarea provided on the validation page. You can input as much or as little code as you need. The validator will return the results which will include the number of errors and where they occur (if there are any errors). If there are no errors, the validator will tell you that the code was successfully checked and 'passed' the test.

Practice

Online code editor
Practical examples
Practical exercises
Step-by-step tutorials

Reference

Terms glossary
Reference material

Rate this site

Rate this site
Visitor comments