Some Common Html Validation errors you should keep in mind

Some common standards that i keep in mind while writing an html code:

1. Avoid using html tags inside <script>:

It would be good if you avoid using html tags inside script tags on the page.

<script type=”text/javascript”>
// This is an error!
// –>

As mentioned in the HTML 4 Recommendation’s note about specifying non-HTML data in element content, end tags are recognized within SCRIPT elements, but other kinds of markup–such as start tags and comments–are not. This is an unintuitive quirk of SGML for elements defined to have CDATA content.

Authors should avoid using strings such as “</P>” in their embedded scripts. In JavaScript, authors may use a backslash to prevent the string from being parsed as markup:

<script type=”text/javascript”>
// –>

2. Use Query strings wisely:

You will be using & to tag on multiple query strings. But please do ensure that you don’t use entity keywords in your URL. For instance &copy would give a copyright symbol. &section would give replace &sect with a symbol. You can get to know about the entities here.

3. Incorrect nesting of elements:

Nest html elements properly in the proper order in which they are created. For instance, check the example below:

Incorrect: <b><i>Hello World</b></i>

Correct: <b><i>Hello World</i></b>

4. Always use NAME attribute with IMG or FORM.

5. Use all lower case letters in a DOCTYPE

In a DOCTYPE, the formal public identifier–the quoted string that appears after the PUBLIC keyword–is case sensitive. A common error is to use the following:

<!doctype html public “-//w3c//dtd html 4.0 transitional//en”>

Here the formal public identifier (FPI) is all lowercase. The validator does not recognize the document as HTML 4.0 Transitional since the expected FPI for HTML 4.0 Transitional uses different case:

<!doctype html public “-//W3C//DTD HTML 4.0 Transitional//EN”>

6. “Missing a required sub-element of HEAD”

If you receive the error “Missing a required sub-element of HEAD”, check that you have included the TITLE element in the HEAD. The TITLE element is required in all HTML documents.
7. Avoid Uppercase letters in XHTML tags, thought HTML is fine with it.

In XHTML, unlike HTML, element and attribute names must be all lowercase. For example, onMouseOver is an invalid attribute in XHTML, which requires use of onmouseover instead. Either is fine in HTML.

8. Please do not forget to validate your HTML. You can use the one recommended by W3C:

Feel free to leave a reply here...

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s