Barbara Leeds > Samples >

Validating an (X)HTML Page

Purpose

To ensure that your web page works properly with a wide variety of user agents, it is important to meet standards. The World Wide Web Consortium (W3C) provides free validation services to check your pages.

Using the W3C (X)HTML Validator

Open the W3C Markup Validation Service: http://validator.w3.org/. Choose one of the options:

Note: If your page is behind a firewall (perhaps in a corporate intranet), you may not be able to validate by URL. In this case, make sure the page exists as a file on your computer (copy it if necessary) and validate by file upload, or copy the contents of the file into the validator screen and validate by direct input.

Tips

Doctype (and Namespace)

Specify an appropriate doctype (plus namespace for an XHTML page) at the beginning of the document, before the <head>. For example:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

or

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

Content-Type

Specify an appropriate Content-Type metatag at the beginning of the <head>. For example:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

Content vs. Presentation

Remove presentational markup from your (X)HTML page. Instead, use semantic markup and external stylesheets.

Quotation Marks

To achieve symmetrical open- and close-quotes (‘ and ’ or “ and ”)—as opposed to typewriter-style identical quotes (' or ")—that display properly and validate, use the following entities:

Symbol Name Appearance Entity
Open single-quote &#8216;
Close single-quote (apostrophe) &#8217;
Open double-quote &#8220;
Close double-quote &#8221;

For example, to display this:

He asked, “Is that ‘Little Maggie’?”

code this:

He asked, &#8220;Is that &#8216;Little Maggie&#8217;?&#8221;

Note: Microsoft products may insert noncompliant entities as “smart quotes”; change them to the entities listed above.

Errors

If you have errors, correct them one by one, from the beginning. Correcting an early error may resolve several later errors.

Announcing Compliance

The W3C allows you to add their compliance icon to any page that validates (see below). The icon is clickable, so that you (or anyone else) can easily revalidate the page.


Valid XHTML 1.0 Strict barbaraleeds@yahoo.com