Doctypes And Validation

Posted in HTML | Posted on 10-05-2009-05-2008

In the previous tutorial we discussed the significance of browser compatibility.  Our goal is to have our website display the same in as many web browsers as possible.  One of the steps to achieve this goal is to validate your website.

The organization responsible for creating the sets of web standards is the W3C (World Wide Web Consoritum).  You should visit their site to learn more about them and their goals.

For our site to validate with no errors, we must first decide which  Doctype we are going to use.

In XHTML 1.0, there are three Doctypes:

XHTML 1.0 Strict

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>

This Doctype is used for clean markup.

XHTML 1.0 Transitional

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

This Doctype is used when you want to use deprecated tags.

XHTML 1.0 Frameset

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd”>

This Doctype is used when you want to use frames.

You can view a list of the tags that are allowed in these specific Doctypes at the W3Schools website.  In addition, there are other Doctypes that you can use besides XHMTL 1.0.

After we have declared what HTML flavor we are going to use, it’s time to validate our markup.  To validate your site,  go to the <a href=”http://validator.w3.org/”>W3C Markup Validation Service</a>.  Just input your web page address, web page code, or upload your file from your computer, and click check.  The validator will tell you if you have any errors on your web page.

Validating your site is a very good practice for obvious reasons.  A lot of sites including major sites on the Internet do not validate in accords to W3C standards.  So if your site doesn’t validate, it’s no big deal.  It’s up to you if you want your site to validate or not.  Sometimes you may not get your site to validate for various reasons.  In conclusion getting your site to validate is good design practice.  Just remember that having a site with no errors does not guarantee that your site will display correctly on every browser.  You should still check your site for cross-browser compatibility issues.  The browser might have bugs.  You might have to work on some hacks.