ACOM: Web Design Tutorial Site | ![]() |
|
Related topics |
ValidationThe World Wide Web Consortium - or W3C - are a collection of computer scientists and other interested bods who periodically gather at the Massachusetts Institute of Technology (MIT) to set standards for HTML and other uses of the Web. Their pronouncements do not have the force of law, but are recommendations, and ones sometimes ignored by the manufacturers of web browsers (as doing so provides a means to acquire a commercial edge over competitors). But it is precisely because browser "standards" vary so much that it is important to have some form of central authority to which prospective web designers can refer. If you want a gripping read, check out the HTML 4.01 standard; though seriously, anyone intending to take up web design as a profession (or part of their profession) should keep themselves up-to-date with developments at the W3C. The W3C have provided an automatic validation service. As you can see in the screen shot below, you can enter the URL of any given web page and have it checked for conformity to standards. Remember that the first lines of the pages on this site are as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML LANG="en">
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=iso-8859-1">
<META HTTP-EQUIV="Content-Language" content="en">
.... rest of code follows...
These tell the validator (and web browsers also) which version of HTML is being used on the page, and what the character set and language are (en = English). These tags are important in other ways as well, as they enable specialist browsers (e.g, those used by the disabled, or people with vision problems) to render the page correctly. As I've already pointed out on the page about structural tags, they should really be included on all web pages. If you try using this validation service without them you will have to manually set the standard and the character encoding, or you will see a "fatal error" when you try and validate. Anyway, as you see, you enter the URL and press the "Validate" button. You can change the standard as shown, but if you've put the tags in as above, it should successfully "detect automatically". ![]() Apart from the knowledge that doing this ensures your pages conform to the correct standard, and will therefore be robust and almost certain to be rendered correctly in any browser, there is one big advantage to doing this. Sometimes you simply can't work out why a page isn't rendering properly, and while you're sure that somewhere you've missed an angle bracket or a quotation mark, you just can't find it amidst those lines and lines of code. So run a quick validation - it won't take a second to reveal the problem: ![]() Though in this case the actual message could be clearer, the validator clearly shows the line with the missing quotation mark. You'll notice that at the bottom of this error report there will be a full copy of the HTML file so you can check the line numbers against the report. As well as missing punctuation like this validation will pick up improperly nested tags, missing closing tags, and tags placed in the wrong order (block-level tags within inline tags, for instance). Sometimes one simple mistake can cause dozens of errors, particularly if it's something important like a missing </TABLE> tag. If an error is highlighted, but the code looks OK to your eyes, keep going until you find something obviously wrong, change that and try again. You might find that several errors disappear at once. Eventually, you should achieve this: ![]() It's not quite as simple as that. (Did you expect it would be?) For a start, you actually have to have a URL to use this service; you can upload files from your local machine, but it's better to have them published on the Web. At Leeds Uni that's just a matter of moving them into your WWW directory, but you should still bear it in mind. You can't validate straight from your M: (or A:, or C:) drive. Also you need to be aware of a few quirks of validation. The first problem comes with frameset documents. You must ensure that the correct standard is being applied - see the screen shot above, noting the "HTML 4.0 Frameset" entry. Many things that you'd get used to typing without even thinking about it, such as putting WIDTH=65% instead of the correct WIDTH="65%" would make no difference at all to most browsers, but would cause the page not to validate. You will need "dummy" ACTION="" attributes in every <FORM> tag, even if these are just being used to put "stand-alone" buttons on a page. And there are some absurdities built into the standard. For instance, with possible values of the SHAPE attribute in the <AREA> tag, the abbreviations poly and rect are in the standard instead of the full words polygon and rectangle; yet circle is in the standard instead of circ!! There is one important thing I've introduced on this site which will not validate, and that's the use of the NAME attribute in the <IMG> tag to produce rollover images. The reason for this is not so much a problem with NAME as with the whole idea of the <IMG> tag. For information, see the note about the <OBJECT> tag. As said there, I have decided to let the problem slide for now. Despite some sillinesses, this is a useful service. It can help tidy up the code produced by HTML editors as well. If you run your page through a validator, and through a text-only browser emulator, and it looks fine in both, you have almost certainly written an extremely robust and correct page that anyone, anywhere in the world will be able to view as you intended. And with web design, that's as much as anyone can ask. Even though, the first time you use the validator, it can be a horribly dispiriting experience to see just how far from acceptability your code actually is, it's worth persevering and learning the rules. You will be a better web designer for it. |
Material on this site is © Drew Whitworth and ACOM, 2002. Permission will usually be given to reproduce material from this site for non-commercial purposes, if credit is given. For enquiries, e-mail Drew at drew@comp.leeds.ac.uk.