The W3C HTML Markup Validator is very useful for assuring that the HTML code your site generates is valid code that is compatible with any browser that complies with the coding standards. However, the error messages generated are sometimes very cryptic and hard to understand. We can take the mystery out of some of the messages.
The w3C HTML Markup Validator can be found at http://validator.w3.org/. The validator should be considered a tool to be used whenever a new web site is created or whenever changes are made to a web site. It can produce some surprises when a web site has never been validated. Most site web designers incorrectly assume that if a page renders correctly, the code must be correct.
We provided instructions for using the W3C validator in another article. This article focuses on some of the error messages you may see.
There are three types of messages that may appear when using this tool.
= Error. An element of the code does not comply with the Doctype standard set for the page.
= Warning. Warnings are an FYI used to indicate a soft error or recommend a better way of doing something.
= Information. Gives more information about an error. The information message frequently follows an error message to indicate where an HTML tag or a starting element, such as a div tag, first appears. For example, if you have a div tag that is not closed in the code, the message may indicate where the opening div statement appears.
It is important to note that errors are not necessarily mistakes that will cause problems with either browsers or search engines. An error or a warning simply indicates that the code does not comply with the standard set using the Doctype declaration for the page.
When reviewing the errors, some messages can be disregarded. The trick is in understanding the code well enough to be able to identify the difference between an actual coding error and one that simply indicates non-compliance.
Most messages are easy enough to figure out, but some do confuse people because they appear to indicate errors for what looks like valid code. The secret to understanding most of these issues goes back to the Doctype posted in your web page code.
No DOCTYPE found! Checking with default HTML 4.01 Transitional Document Type. You need to declare a Doctype so that the validator know which standard to use for rating code compliance.
there is no attribute “TOPMARGIN” TOPMARGIN, LEFTMARGIN, MARGINHEIGHT, and MARGINWIDTH are all Internet explorer browser extensions and attributes that go back to the “browser wars” days in the 1990s when Netscape and Internet Explorer competed for market dominance. Both created their own browser extensions that were never part of the W3C standards. When you see these messages, it is an indication of use of a very old coding style.
required attribute “ALT” not specified One of the most common messages. Since HTML 4.01 this attribute is required for use with the IMG image tag. The ALT attribute is used to briefly describe the image. If you do not wish to describe the image, simply use alt=”” in the image tag and the error message will go away.
there is no attribute “BORDERCOLOR” This is another pre-HTML 4.01 table attribute that has been deprecated. Use CSS to define the border color for a table.
there is no attribute “HEIGHT” Typically found when the HEIGHT attribute is used with a TABLE tag. As far as I can tell, the use of the HEIGHT attribute with a TABLE tag has never been valid, nor has it ever been part of the coding standards. When using HEIGHT with tables prior to HTML 5, the attribute is applied to the TD table element. Using CSS is a better way to define table cells. With CSS, a single class selector will set the TD height for an entire table.
The center element is obsolete. Use CSS instead. The CENTER tag has been deprecated since HTML 4.01. Do you know where I saw this error message? I found it when validating Google’s home page. Google’s simple home page frequently contains 25 or more coding issues that do not comply with w3C standards.
Every now and then we see what I call a “cascading error”, which means that one coding issue creates a cascade of sometimes 5 or more error messages in the validation results. HTML nesting errors frequently cause issues like this. If you cannot identify the root cause of an error that appears to produce numerous nonsense errors, start fixing the errors one at a time and re-validate the code after each fix.
The W3C does have a page that lists most error messages along with a brief explanation, but these are mostly the same types of cryptic message that are displayed in the validator.
If you are seeing some strange message in the W3C Validator, try posting the messages here and we will see if we can figure them out. Just post individual messages and not an entire range of error messages. It is not unusual to find web pages that show over 200 errors when using the validator.