What are doctypes all about, and how are they used in HTML pages?
Let’s start at the beginning. Every HTML page you write really should have a doctype at the top of it. It should look like this –
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
or like this
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/strict.dtd”>
There is a third type for framesets, but will ignore that one, as hopefully nobody is using frames any more :).
In essence, these two commands either tell the browser that they are going to get a completely CSS document (the strict) or that they will get a document that has formatting done at least partially without CSS (loose, also known as transitional).
So for example, say that you are using CSS but that you sometimes use commands such as:
ALIGN (on images)
These types of commands would NOT be accepted in a “strict” environment.
It is critical that you match your doctype to what you are doing. If you really are going 100% CSS and not using any of these commands any more, then go for strict and make sure you validate a large chunk of your pages to make sure you didn’t miss anything. Otherwise, use “loose” so that your legacy code will be accepted.