Well, it can be handy if you are trying to troubleshoot a broken page. But presumably these pages have been tested in all browsers and have been found to work, so it really doesn't matter if the validator is throwing a hissy. All the same, it's a bit embarrassing to see trendsetters like Google and Yahoo still vomiting out code like that. :rolleyes: From a quick glance, it kinda looks like Google has just slapped a new doctype on an otherwise old and outdated page.
The HTML 5 doctype is equally valid on pages using HTML 2. You probably just selected the wrong version of HTML for the validation. Where the version info isn't in the doctype the validator assumes the latest version as the default value to set simply because it has to choose one of the versions.
It was automatically HTML5/
As long as you're writing HTML or fauXHTML, browsers will be pretty tolerant of errors in your code ... but remember, if you ever start writing real XHTML, a single validation error will bring the entire page crashing down and it will display nothing except an error message.
And the key words there are "pretty tolerant". Browsers are generally good at working out what people meant to write and what they wanted to happen, but they aren't psychic and they don't always get it right. Sometimes the code is so broken that they don't have a clue what to do ... but what is more common is that one browser (usually the one that the author is using!) guesses correctly what was intended, but others don't ... and that's when you get buggy layouts that don't work properly in some browsers. You'd be amazed how often layouts that appear screwed up in one browser but not another can be tracked down to validation errors.
But ... your page works fine in all major browsers around today. Do you need to worry about validation?
I would say "yes", for three reasons.
1 - you haven't tested your site in every possible browser out there, so there's a risk that if it has any bugs in the code, these might manifest themselves in a browser you've not tried. OK, so it won't affect a huge number of people, but it will affect some, and that's a problem for those people.
2 - you haven't tested in browsers that haven't been released yet. The bugs that you've got in your code might still give the results you wanted in Chrome 24, but who is to say that they won't wreak havoc when Chrome 25 comes along? Get into good habits now, and it will serve you well in the future.
3 - in most cases, there's no reason not to write valid code. If you've got unencoded ampersands in your URLs or badly nested elements, fix them! It isn't a big deal, and it won't break anything. Because having errors that you don't need to have leads to the next point ...
4 - the chances are that your site is not complete or finished, you will be adding to it or changing it. And one day when you're making one of those changes, you make a little mistake with the code and introduce a validation error. And this one does cause problems. So you go to run the page through the validator to find the source of the problems and Whoa! There's a hundred errors on that page, most of them absolutely nothing to do with this problem, but now you've got to sift through all of them to find the one that's causing the issue.
I'm not saying that every page must validate. I have pages that don't validate, for a variety of reasons. But the thing is, I know what those reasons are. And those are cases where I have made a conscious decision that I want to use code that I know isn't technically valid, I know why it isn't valid, and I know what the risk of it causing problems is. If you don't take that care, you run the risk of it going pear-shaped.
That's what is supposed to happen but not all browsers have actually implemented it that way. For example IE9 progressively renders the page as it reads the code and so will display the part of the page up to the point where the error in the XHTML occurred (that is to point where the missing tag should go). Other browsers will display an error message and some will then display the page up to the point where they considered the error to have occurred (eg. up to the point where an opening tag is missing its corresponding closing tag). See http://www.felgall.com/invxhtml.php for an example.
In IE9 since the error in that page is missing tags just before the </html> tag the entire page renders as if the tags were there since IE9 considers the error to have occurred at the point where the first tag is missing. No error message is produced so the person viewing the page doesn't know if they are seeing the whole page or not.
Chrome displays the following error message:
This page contains the following errors:
error on line 6 at column 106: Opening and ending tag mismatch: p line 0 and html
Below is a rendering of the page up to the first error.
and because the </body> tag is missing there is no content to display prior to the first error so the error message is all you see.
Firefox displays just the error message and tells you where the error occurred.
XML Parsing Error: mismatched tag. Expected: </p>.
Line Number 6, Column 101:<p>This page is real XHTML but it has some tags missing and so should not be able to be displayed.</html>
As you can see, even the browsers that do report an error disagree as to exactly where the error occurred.
Thanks for that post. It answered a question I was going to ask. A local "web designer" has posted on her Website that she doesn't think it is necessary to validate code, that it can actually cause problems, and that she felt it was "expensive" to run down errors, when the Website appeared to work just fine in her browsers (and of course she doesn't say which ones she tests her sites in, but she did mention problems and fixes for IE.
I thought that sounded a little strange, since she is supposed to be a "designer." But her Website takes over 15 minutes to load, (it's a WordPress template) and one that she did for a former client of mine (I was glad to get rid of the lady; she was a real PITA) doesn't load any faster, and it is also a Wordpress Theme . I had created a beautiful hand coded site for her, and all the pages validated (the site loaded in seconds, too, evien on dial up, which we're stuck with here); but, she was impossible to work with, so after a year and a half she left. Now her site is like millions of others and it doesn't load. When I saw what this woman had written, I laughed.
Thanks for the answer.
This topic is now closed. New replies are no longer allowed.