Let's say that you have the following code sequence for a header in your page: <H2><I>A nice header in italics.</I></H2> And it looks like this (in a nice contrasting pink for those of you with CSS aware browsers):
A nice header in italics.
Okay, that's pretty straight forward stuff, except for one little item. Only that line is supposed to display as an italicized header. Well, it's a header alright! But the italics continue into this paragraph. Wonder why? Because you forgot to close the <I> tag.
Now what happens if you were to place the <I> & <H2> tags in the proper order? It looks like this:
Another nice header in italics.
Bingo! An italicized header (and nothing else!). Missing a closing tag caused an undesired result. A strange side effect of this relatively minor gaffe is that Netscape 3.X/4.X renders everything up to the word "Now" in the previous paragraph as part of the header, but not italicized. MSIE & NS 6.X merely renders the text in that paragraph up to that point as italicized text. Opera, disappointingly, renders item both the same way. Obviously, that wasn't your intent, but it's what you got. Would you have caught that the tag was missing? Probably. How long would it have taken you?
Running the page through a validation service or software would spot the tag nesting error immediately and alert you to the fact that there is a potential problem and allow you to fix it before your audience has a chance to see it.
What is validation? Validation is a check of the grammar (syntax) of the code for your web page. Is it necessary to validate to have the page display in a web browser? Maybe. Maybe not. It all depends upon how well the code was written and how well the browser can interpret the code you've given it.
For example: If you (the reader) were a native speaker of English and I wrote the following sentence:
The horse jumped the fence over.
In spite of the syntax errors, you would probably be able to determine that I was trying to tell you that there was a fence and a horse jumped over it.
Imagine how confusing that same sentence might be to someone who speaks English as a second or third language. It possibly wouldn't make much sense to them. This is the same scenario you faced in the example above. The browser correctly interpreted a header, but couldn't determine what to do with the italics, so it ignored it.
There are over 200 web browsers in the world today. If your code confuses the browser, it may cause the browser to render a result that you didn't anticipate or want. This can be as simple as the example shown above, or as drastic as the page not displaying at all.
Does every page need to be validated? Yes. No. Maybe. Short answer- Maybe. Long answer- Maybe. What is the purpose of the web page? Who is the intended audience? Is it a personal site, that will only be visited by friends and family members? Is it a business site? Did you take someone's money to design the site?
Another factor to consider in the validate or not equation is this- where will the site be displayed and accessed from? Is this web page going to be displayed on a intranet, under controlled conditions? Is everyone using the same version of the same web browser? Or, is this page destined for the open Web?
Does this page target the general populace? Or a fairly narrow section of it? All these questions need to be answered before you can decide whether to validate a page or not. Do you care that some people won't be able to see your page displayed? If the answer is no, don't bother validating it. If the answer is yes, you should consider it a mandatory step in web page authoring. At the very least, validation can catch those silly little errors that can escape casual review.
Validation is mostly a state of mind. It's part of the web authoring process, much like checking your pages in different browsers to see if they work correctly.
Using Cascading Style Sheet (CSS) technology would eliminate the problem, because all you need to code on the web page is the <H1> tag, but that's another story.
So, you've decided that validation is a good thing and you run the page through a validator. What happens if your page doesn't validate? Do you have to completely scrap it and start over? No, not necessarily. There are several things that don't validate, but may still work. As an example, if you go to this page you'll notice that the page has a page background image and a background image in some of the table cells.
Under the DTD listed for that page, the table cell background properties do not validate. Do they work? Depends on your browser. What happens if they don't work? Well, in this case, you end up with brown text on either a plain brown background, or brown text on a image of wood. Doesn't that look goofy? Yes, but the page displays and is readable.
Doesn't validate, may or may not work. Should you use it? Your decision, but you should apply the does it work test before you use it.
