Validation: Why bother?

image

If you give your web page a doctype, then you can make use of a validator to see that the markup is in good condition.

Smarten up your act. Validate your web pages so that web browsers know what they are getting and can interpret your HTML correctly.

Validation is an important part of web site implementation because if a page validates it means that the main browsers will be getting well formed markup and (in theory) should be able to render your design as expected.

furthermore...

Quite often web designers will struggle to get their pages to render properly and often this is because their is some trivial error on the page. validation can help to detect those pesky little syntax errors that might be bugging your HTML markup or even your CSS. Maybe you have a missing closing tag or your CSS is short of a closing curly bracket. validation may pick this up .... but

Interpreting the validation report

Unfortunately, a failed validation often shows a great number of incomprehensible error messages and, at first you may be put off the whole process! Don't be discouraged, though, because one error (eg missing closing tag) will throw up more errors than the one that is causing the problem. The trick is the fix one error at a time and then repeat the validation. You may be pleasantly suprised, that a validation report that show 6 errors can be fixed by mending just one problem.

Pairing Off the Tags

XHTML is less forgiving than HTML so you will need to dig deeper to correct the errors. Often the error is a simple mismatch between the opening and closing tags. Complex markup may involve a lot of divs, and you may have one too many opening or closing divs. Text editors such as BBedit or Textmate (sorry I'm a MAC user) as well as Dreamweaver (in code view), have the ability to fold or select the complete element from the opening to the closing tag. This should help you identify missing tags.

Children with the Wrong parents

Another typical problem is having tags inside other tags where they don't belong. You can't have a paragraph inside a heading or vice-versa. You can (and must) have a list element inside a list (unordered or ordered), but you can't have a list element outside its parent.

Forms and Function

Unfortunately forms and their components do often throw up errors and you really need to check the rules here.

Doctype

Validation is dependant on your web pages having a docype declaration like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

The validator will check your markup against the specification (DTD) for that document type. XHTML is more rigourous than HTML and XHTML version 1.1 strict will be more difficult to valdate, being well -- um strict.

Other tools

Firefox has a very nice extension called Web Developer and you can get from the author, Chris Pederick. His web site is here. The tools include a set for validation and the most useful aspect of this is that you can validate a local web page. In other words, you don't need the page to be live before you validate.

Posted on 09 Nov around 9pm

Tags: • validation doctype www3