Validating your web site code can often
be confusing and annoying. It is NOT a requirement of anyone, but
maybe something extra you may want to offer to a client, or just to test
your skills. Easy2Confuse offers some suggestions and tips on validating
your web pages.
The first thing many seem to
overlook on their web pages is the !DOCTYPE comment line at the start of
the page. With many of the browsers out today this makes little
difference in the display of the page but if you wish to write
correct validated code it is required. There are several formats and
standards all of which are needed to set the Document type for the HTML
standard which the page will be valid at.
For example if you use the Doctype of
it would require a different HTML
standard from say
There are far
too many of these standards to list them all here. ( over a
dozen ) and each sets the correct HTML or XHTML standard at
which the page is going to be valid at all of which is
determined by the correct language standards as defined by the
W3.org group which sets the standards for most of the Internet
Language standards. You however MUST select one to have a
valid HTML page. The older standards such as those shown above
are the most supported, however the newer standards will offer
some newer features on WebPages. Oh and do not assume your
WYSIWYG HTML editor is going to write valid HTML code. Few do
actually so if you hope to do valid HTML or XHTML you will
need to learn how to write code to some extent and not rely on
a What You See Is What You Get editor.
Perhaps the next
biggest problem to get the page to validate is the encoding
used and one seldom mentioned even by the W3.org site. I
personally have found without an encoding tag validation
seldom can be done. For most this would be the way to add the
encoding identifier.
Of course this
is added in with the other Meta tags in the header and nothing
is ever as simple as it seems. The placement as a meta tag
only is good for the HTML 3.x and 4.x standards, and at the
start of use of the XHTML standard the encoding is included in
the DOCTYPE area at the start of the document. This would be
an example for XHTML 1.0 :
Note that the encoding is now a tag that
starts with a question mark.
Aside from new tags and opening and
closing tags in the correct order, I have found that the any Java scripts on pages often become a problem with the validation process. There are
several reasons for this and do not assume that the problem is always
going to be your HTML. Many web pages have banners inserted by the web hosts
and these generally do not have validated code and will result in errors.
If you are on a site that includes a banner or popup you may wish to try
validating your HTML code by uploading the file to the validator on the
w3.org site as opposed to providing the URL for that purpose. Look at the
source of your page after you have uploaded it to your host as many will
add the scripts or banners in the code and you can find it in the source
of your page. Most of the FREE Web hosts include banners and/or popups.
Most of these include scripts and items known as cookies or webbugs in
those banners or popups which are generally the item that prevents
validation of pages on those hosts.
If you have your own Java scripts on your
page, many have just the simple
<script> and </script> for
tags.
In many versions of HTML / XHTML these
are no longer valid. So if you see errors on validation with your scripts
and their tags you may wish to try converting your script to use;
<script type="text/javascript">
and </script> for tags instead.
In many cases these will work, however in
some cases they will show an error so make a back up copy of your script
by saving it to notepad before you try to change the tags on your scripts.
Some scripts just do not accept the change - most likely because they are
not written in Javascript but MS JScript instead. In such cases you can
only try to find an updated script that may work for your page which does
the same thing.
WHEW!! once you have to correct code in place,
take a trip to http://validator.w3.org/ and see what happens.
Suggestion: Many clean their code up first if they
used FrontPage or Net Fusion, or DreamWeaver to build ~ check for errant
space code, etc. You may want to run TIDY online or download
Tidy and run at your leisure. first, then validate.
It's all up to you.