by Vivienne Trulock
So, how do you know that you've written your documents correctly? Fortunately, there are many validators which will check your code for you, but before you can use them you will have to add some tags to your document so the validator knows what it is looking at.
Tye most important of these is the doctype. This explains to the validator (and to browsers) what version of html your document is written in. Just copy and paste the appropriate doctype into the very top of your HTML document (before the <html> tag).
This is the form of HTML which must be used if there are any deprecated elements in your HTML page .
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
This is the strict form of HTML which doesn't allow any deprecated elements.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
If you are using XHTML, an even stricter form of HTML you will need to follow the following rules in your document:
This is the same as same as HTML 4.0 Transitional except for the XHTML rules
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
This is the same as same as HTML 4.0 Strict except for the XHTML rules
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Even stricter, with no deprecated elements.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
As many people all over the world speak and create HTML documents in many different languages, the validator needs to know which character set you are using in your pages. For most western languages, the most commonly used encoding is 8859-1. Simply copy the code below into the head area of your web page (between the <head> and </head> tags).
<META http-equiv="Content-Type" CONTENT="text/html; charset=iso-8859-1" >
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
Probably the most well known html validator is on the w3c website. Simply browse to your file on your own computer and then press the 'Check' button. Errors are clearly shown with a brief description of what is wrong.
You can also validate your CSS the same way.
Try to validate the review exercises as you complete them and to correct any invalid code.
When you have completed the first exercise on 'Hearing' you can view the valid code below:
Now that you know how to create a basic page, the next step is to make an entire website.