Step 9 -- Meeting web standards.
Errors in HTML code
What happens if you make a mistake is your HTML or XHTML code? Suppose you open a block with the tag <h1> and close it with </h2> or just forget the closing tag entirely and move on to <p>?
What happens depends upon the browser. A particular browser like Firefox may choke on a missing table tag while Internet Explorer displays the page perfectly, or vice-versa. You may be happily proliferating a mistake in page after page because the code works on your Opera browser and the rest of the world complains. What to do? One option, of course, is to test your code in many browsers, definitely worth doing if you can. Some web sites choose the option of telling users "Sorry, this page only works with IE5", typically something you see with certain secure pages. The option we suggest is to code according to one of the more modern standards and then validate your code to see that there are no mistakes. With this testing, also inform the browser about which convention you are using and chances are your web page will display well.
Specifying the standard you are using
Validating HTML or XHTML
This location at the w3 web site is prepared to test any of your web pages or pieces of code you'd like to try out: http://validator.w3.org/
You will see three choices
- Give a URL, the choice if your page is already accessible on the web.
- Browse for a file, the choice if you are working on pages before transferring them to a web site
- Copy in some code.
If the code fails validation (oh, the shame!), a list of errors will appear. As in all programming, the trick is to figure out what the messages mean. The problems are usually obvious and you'll see reference to a missing tag or mismatch of tags, so just fix it in your file, back up one page and click the check button once again.
Errors can cascade in that one error can make other code seem to be in error (validators are only human, after all), so fix the errors starting with the first ones unless you can defintely see the problem in later errors. Don't waste time puzzling over an error far down in the list until you have fixed the first errors.
The validator has the wonderful reinforcement that errors are reported with a bright red bar at the top of the report and NO errors is announced with a green bar, always a thrill to see. Once you receive the green bar, instructions appear on how to place a certification of goodness on your very own page. See ours below!
Validating CSS
At the site http://jigsaw.w3.org/css-validator/ you can find a validator for your CSS code.