I took some heat in the All the Web forum for the html code on my personal site. Someone said they used a html validation tool, and found tons of errors. So I used it too, and yup tons of errors!
Now I had used this tool before, and I can't make any sense out of the results it gives. It gives tons of errors for things that are completely appropriate. It gives an error for the <html> tag for gods sake!
It seems like these tools are very highly spoken of, but are they really useful? Much of the code that is showing as errors is working just fine in the site itself. So I am having trouble finding the problem. Thanks.
Hope this is an appropriate forum, I didn't want to continue it in the All the Web forum.
Well, a lot of code "works" -- in the sense that the major browser's will find a way to render the page -- and yet is not accurate. The web is in a kind of rock and a hard place position. Standards are difficult to create and support if there needs to be legacy support for the non-standard kludge. Yet HTML browsers were, from the beginning, designed to forgive "bad" code.
So, validators report based on standards violations, even though they may be common practice. Little by little, different non-standard code will stop working, in browsers, in getting spidered, etc.
IMO, it's worth the time to get our code to validate. It makes our sites more universally accessible, and helps move the web forsward.
when you get an error with <html> it probably means you don't have a doctype before the <html>.
Also, doesn't it just feel right to nest your HTML. I find it satisfying somehow.
The problem is that just because a web browser can render a page, doesn't mean that page is proper HTML. Web browser go out of their way to try to render something. The thing is, not all web browsers are equal. A spider is another kind of web browser. So just because one spider understands and gives your site a good rating, doesn't mean the next one will, unless you validate. A validated site means that your site conforms to the web standards. If your site does not conform to the standard, it is not a bug if the search engine doesn't handle your site correctly, for example not finding the title tag.
That said, the first thing to do is to add the line to the top of your html, before the <html> tag:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
That will make many of the validation errors go away. This is an instruction to the thing interpreting the HTML exactly what rules you are going to play by: which tags and attributes are considered correct and allowed. There have been several versions of HTML. HTML 4.01 is not the latest one, but will be the easiest to make your HTML validate against.
If you run into other questions that come up when you try to get the rest of the document to validate, bring them back here and we will try to help.
One other tip: When you are validating, only concentrate on fixing the first problem that it reports, then revalidate. The other problems are probably caused by that first problem.
Great info to have! Thanks Xoc.
BTW, welcome to WebmasterWorld, andytt!