The DOCTYPE declaration

The W3C Validator will check your pages based on the DOCTYPE you have specified at the top of your source code. If you use a WYSIWYG editor, it probably won't have added this information and you will have to do it manually. The DOCTYPE looks something like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

What all this means is that you are using the current HTML standard (HTML 4.01), 'Transitional' means that it will allow some older tags that are being deprecated and presentational elements like <FONT> and <B> whereas 'Strict' means 'completely by the book'. 'EN' means English, which refers to the mark-up language, not the contents of the page.

Another form of the DOCTYPE declaration is this one:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

The second line is the 'switch', which forces some browsers to go into Strict mode regardless of the Transitional statement earlier. Add this only if you are certain that your readers are using the very latest browsers and your coding is 100% compliant.


Browser Latitude

The W3C Validator is a black and white, pass or fail situation with no middle ground. It will fail pages that work perfectly well in all current browsers - including some of mine. This is because current browsers still have some, (if not as much as before) latitude or forgivingness built-in. You can't count on this always being so. If you want your pages to keep on working, make them W3C compliant now.

There are some potential problems that the W3C Validator won't show up. A page that is perfectly valid in terms of coding might still look wrong. The important principle of separating structure and content is like building two houses from the same set of plans - without dimensions. The houses could have completely different sizes, finishes and colours. One could be okay for humans and the other only for dolls.

The HTML is the 'skeleton' of a Web page and the 'look' is determined by the Style Sheet. Well, that is the principle and where things are headed but in the real world, the legacy of older browsers and Web pages still in use means that you can never be sure of anything working correctly anywhere.

In the end, it's your decision. You can address the lowest common denominator and design a page that works at a basic level for everybody or you can use the latest technologies that only work in the newest browsers - or anything in-between.

Ignore the problem and it will go away. Unfortunately, using a validator like the one at W3C can be a little confusing and even frustrating. Why is it giving errors when the page works just fine in every browser you've tried it in? Is it really possible to get an error-free page and if you did, would it work in any browser?

Well, just like WYSIWYG editors, there are no bug-free browsers. If a browser is interpreting a page of HTML and comes across something it doesn't understand, it should ignore it completely. If Microsoft Internet Explorer sees a <chuckle> tag in HTML 4.01, it just pretends it hasn't seen it and nobody really cares.

The W3C Validator, and any other one of any value, will complain bitterly that there is no <chuckle> tag in this version of HTML. That's what it is supposed to do.

The browser has dealt with the problem by ignoring it but the validator isn't too happy about you taking the mickey.

Not all such problems are so clear-cut. There is a point at which any browser gets utterly confused and can't make any sense of what it is given. What it does in that case is anyone's guess.

Some common validation errors and what they really mean:

Error: there is no attribute "LEFTMARGIN" for this element (in this HTML version)

Error: there is no attribute "TOPMARGIN" for this element (in this HTML version)

Error: there is no attribute "MARGINHEIGHT" for this element (in this HTML version)

Error: there is no attribute "MARGINWIDTH" for this element (in this HTML version)

What's the worst that can happen?

The browser will ignore these attributes and your graphics won't butt-up against the edge of the page.

Error: there is no attribute "HEIGHT" for this element (in this HTML version)

What's the worst that can happen?

The browser will ignore the "HEIGHT" you set for a table and it will collapse vertically until it encounters some content that stops it from shrinking any further.

Error: required attribute "ALT" not specified

What's the worst that can happen?

The "ALT" attribute for an image is used by screen reading software for visually impaired people and should tell them what they can't see. Sometimes it doesn't make sense to describe an image – like a clear spacer GIF, for instance. The correct thing to do is to provide an ALT = "" – an empty string.

Error: there is no attribute "NAME" for this element (in this HTML version)

What's the worst that can happen?

If you were to address an image in a rollover by its NAME attribute (as is quite common) and the browser ignored it, the rollover wouldn't work and would probably throw a JavaScript error too. However, the "NAME" attribute is undertood by most browsers and valid since HTML 4.01. You will get this error if you specify HTML 4.0 or earlier in the DOCTYPE.

It's getting increasingly difficult to make pages that work in all browsers without resorting to page redirection hacks. At some time you are going to have to decide, (hopefully based on some hard evidence from your server stats), that you are no longer going to support older browsers. Some people are doing that already but exactly where to draw the line is not an easy decision.
No matter how hard you try, sometimes your code will just not pass the W3C Validator test. You might, for instance, have a link to an external banner ad that is serving up non-compliant code. You have to be sensible about such things, absolute perfection is an ideal that doesn't justify insanity.

Meanwhile back on the building site, it's raining hard and all the mortar is being washed out from between the bricks.

The wind has blown away the tarpaulin that was acting as a makeshift roof and the local building inspector has just pulled up in his car.

Send your suggestions and comments to
Com4tzone • web developer digest © 2019-2023
Copenhagen, Denmark