How to validate your web page

Although not an absolute necessity, validating your web pages is a good habit to get into to help ensure your web pages function properly in all web browsers and search engines.

What does validating your web page mean?

You validate a web page by using a program to check that your HTML and CSS code do not have any errors.  There are several types of validators: HTML validators, CSS validators, Accessibility validators, and broken link validators.

An HTML validator checks to make sure your page’s HTML code complies with the standards set by the W3 Consortium. There are several different validators, including the W3 Consortium’s online validator which you can use for free.

A CSS validator does the same thing for your Cascading Style Sheets (CSS).  They will make sure your CSS complies with the CSS standards set by the W3 Consortium. The W3 Consortium also provides a free CSS validator for your style sheets.

There are plenty of other validators around that focus on various aspects of your code. Click here for a list of HTML, CSS, and link validators.

Validating your web pages does not guarantee that it will appear as you want in various browsers. The only way to make sure that your code appears correctly in different browsers require cross browser testing. You can find out how to do that in the Checking your web site with multiple browsers on a single computer article.

Why should you validate your HTML code?

Although some argue against validating your code, there are several reasons why you might want to consider doing it.

1.     Compatibility across browsers, platforms, and future versions

Your web page might work in your own browser, but it may contain HTML or CSS errors that might show up in another browser. It is also possible that when a new version comes out, pages that worked before will now be broken.  A little time spent now might save you some time later.

2.     Search Engine Visibility

Different browsers try to compensate for coding errors in different ways. Some browsers may ignore certain broken code while others make assumptions about what the code was meant to do. Like browsers, different search engines might make different decisions about those errors in the page and cause certain parts of your web page or even the entire page to not be indexed. This is really the safest way to ensure that your web page has no errors.

3.     It’s a reflection on you

Regardless of if you test your web site with all the browsers and platforms and find that it works perfectly, other web designers can see the errors in your code.  They will either think you don’t know what you are doing or just didn’t feel like fixing it.  I always felt that my goal is to create a good site rather than trying to look good in front of other designers.  But I try to validate my code anyway so I don’t run into any problems down the road.

Why should you NOT validate your HTML code?

There are a few reasons why you might not want to validate your pages.  First of all, validation does not guarantee that your page will work.  Whether or not you validate your code, you still have to test it in the other browsers to know that it displays properly.

Also, it can take time to convert your pages.  Especially if you have thousands of pages, it takes a lot of time convert all those pages so that they validate correctly. If your pages already work, you might be wasting your time fixing code that might not ever be a problem.

Finally, most people will never check your code.  If the page loads properly, people don’t generally care whether or not your code is correct.  As long as it works for them, they will be happy.

How Often Should I Validate?

Some people validate after every change they make to their pages in order to catch any mistakes immediately. Others validate only when they make a major design change.  I generally only validate after major design changes, because I just don’t have time or energy to think about coding after every little change.

Again, you can find a list of validators in the list of HTML, CSS, and link validation article.

Conclusion

Validating your HTML and CSS code is a good practice to get into because it helps you avoid any problems on your page due to errors in your code, better prepares you for new versions of web browsers, and helps avoid misinterpretation by search engines and other browsers.  However, if you know that your pages work well in the browsers, you could take your chances and save the time of validating.  It is something you should do, but not something you need to do.

Posted on February 1, 2010 at 11:15 am by Scott Butler · Permalink
In: Getting Started

Leave a Reply