Validation errors and how to prevent them
Below are three common validation errors, as we discussed in our article entitled "html: resolving simple xhtml errors".
Example 1: An image without alternate tags:
This image has been created without an appropriate alternate tag. This means that it is completely invisible to search engines such as Google and Yahoo.
Poor (Invalid) Code: <img src="images/your-image.gif">
Proper (Valid) Code: <img src="images/your-image.gif" alt="alternate text here!" />
Example 2: Ampersands (&) cause problems:
Ampersands are typically used to declare special characters. When used alone, they will throw an XHTML error. You can prevent this, simply by converting your standard "&" symbols to "&" instead.
Example 3: Tags that need to be closed:
Most tags need to be closed. This includes images, lists, paragraphs, titles, and even your stylesheet reference. Here are just a few examples.
Poor (Invalid) Code: <img src="images/your-image.gif" alt="" >
Proper (Valid) Code: <img src="images/your-image.gif" alt="" />
Poor (Invalid) Code: <link rel="stylesheet" type="text/css" href="style.css" >
Proper (Valid) Code: <link rel="stylesheet" type="text/css" href="style.css" />
Poor (Invalid) Code: <p>text here.
Proper (Valid) Code: <p>text here.</p>