HTML Validation Errors

What is HTML validation?

Your web pages are made with a kind of "word processing" language called HTML - Hyper Text Markup Language. This language is made up of tags which say how the web page should look. For example, to make bold text, you would use this HTML:

<b>bold text</b>

Everything between the start and end tags <b> and </b> would appear in bold text. As with any language, there are rules (grammar), and the rules for HTML are set by an organization called World Wide Web Consortium (W3C). They have a test you can run to see if your pages meet their standards. If you pass, your pages have valid HTML.

Why HTML Validation Is Important

For a thorough explanation of the answer, visit W3C's Why Validate? page. In a nutshell:

  • Validation helps to ensure your web page looks right, no matter what web browser is being used.
  • Search engines can view and understand the page content. Some errors may prevent your content from being read by the search engines.
  • Pages are more accessible to people with disabilities.

While researching, we found several other great resources for explaining why it's important: WordPress' Validating a Website, one by All Things Web and a very compelling writeup by Owen Briggs. If you're interested in running some tests yourself, check out this list of validation check tools, and this quality, accessibility, and privacy issue checker. And of course, we're happy to help you interpret any test results.

How the Errors Get There

Errors in HTML can be caused by lots of things. Here are the most common causes of errors:

  • Failure to specify the version of HTML being used. This is a very common problem. The first line of HTML in a web page should indicate the document type. It's important to specify this because web browsers try to adapt to the version of HTML being used, and if that unknown (or incorrectly set), a page may look completely different depending on the browser being used.
  • Web page editors can produce invalid HTML. This has improved in the last few years, but some programs just don't follow the standards. The worst offender is Microsoft FrontPage. It inserts all kinds of junk that shouldn't be there. DreamWeaver, another popular editor, does pretty well now, though older versions had some problems. NVU is another one that does a good job. And of course, your can write your own HTML from scratch. We write mostly from scratch around here, because it gives us total control over the HTML.
  • Sloppy editing is another cause of errors. Leaving out information, failure to close or nest tags properly, and careless mistakes can wreak havoc on a web page. Unfortunately, many Content Management System (CMS) programs have errors in the HTML they create, probably because lots of different people work on the programming, and many programmers don't know how to make valid HTML.

How To Find HTML Validation Errors

Validation errors can be found using the W3C Markup Validation Service. It will tell you, in pretty technical terms, what problems it found with your web page. Another way of finding these errors is to use a Firefox plugin called Total Validator. This tool is nice because it provides one-click access to the validation tests, and the results are shown in the context of the page so you can see exactly where the problems are. They also have a web-based validation tool which gives more options, including spell checking and screen shots.

How To Fix HTML Validation Errors

This is where it can get a little tricky. Of course, you can hire us to help you, or if you want to take a shot at it yourself, keep reading.

Common Errors and Their Fixes

  • Required attribute "ALT" not specified. To make pages usable for people with images turned off and the sight-impaired (who may be using screen-reader software), you can set a bit of text to display in place of or describe each image. The search engines like this text, too, because it gives your pictures meaning. These errors are easily fixed by setting the appropriate text for each picture.
  • Cannot generate system identifier for general entity "XXXX" or Found '&' within 'href'. You should use '&amp;' instead of just plain ampersands within web page links.
  • No document type declaration; implying "<!DOCTYPE HTML SYSTEM>".
  • There is no attribute "XXXXX". An attribute is something you add to a tag to change its look or behavior. This error happens when you try to use an attribute that isn't allowed for a particular type of tag, and is usually solved by using CSS to make the setting.
  • Required attribute "TYPE" not specified. These errors usually happen when a file is "pulled in" for use on a web page. The most common types are style sheet files, and Javascript files (web page programming to do stuff like make sure you entered data into a form correctly, or to calculate a mortgage payment). This error is easily fixed by specifying what kind of file is being used.
  • End tag for element "XX" which is not open. These errors are due to sloppy editing, usually. A web page uses tags to do stuff to the text in between the tags. For example, bold text looks like this - <b>bold</b> - in HTML. If the beginning or ending tag </b> is missing, that's a problem. It's fixed by inserting the missing tag so everything matches up nicely.

For more information, see this great writeup from Web Design Group on Common HTML Validation Problems.