Building BobSmithPhotography.net has stopped expanding because I've been overwhelmed with spam on the comment forums. So, if you're here and have questions about web design come and visit Forums, Blogs, Wikis dot com. It has articles that I've written, some of which are also here, and a web design forum as well so you can ask any questions you may have. There is still a lot of good stuff here though, so poke around the links and take a look.

Home » The tutorial » DOCTYPE

DOCTYPE 

DOCTYPE is one of those terms that you've probably seen and just skimmed over.  You may have even seen a DOCTYPE declaration somewhere and thought that it was just too much technical junk to worry about.  Besides, your site looks fine without it.  

Without a DOCTYPE the browser has to assume how you want your page rendered, and it may assume wrong.  You should make sure the browser knows what you intend.  When a browser comes across a page with a DOCTYPE it goes in to 'Standards Compliant Mode' and without a DOCTYPE it's 'Quirks Mode'.  Which sounds better to you? 

So, Which One?
There is a rift between web designers over HTML and the newer XHTML.  Either will work in recent browsers, and they are very similar to each other with just a few minor differences.  As an example, to display the graphic logo.gif in HTML you would use <img src="logo.gif">.  XHTML would be <img src="logo.gif" /> - note the extra slash at the end.  Every tag has to be closed in XHTML so tags that don't pair up like <a> and </a> have to close themselves.

Personally I use HTML 4.  Never had a problem with it and I have had problems getting XHTML to lay out correctly.  Not that it's impossible, but I would rather use what I know works that have to figure out another way of doing the same thing.

But you're free to use any valid DOCTYPE you want.  If you prefer XHTML, use it.  At this point it's a personal decision.

How do I do it?
The DOCTYPE declaration has to be the very first line in your HTML page.  If you are using HTML you can choose from the following:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

I usually go for the second option, the Transitional DOCTYPE.  Strict is a little too, well, strict for me.  If you're designing a frame site you need to use the last choice.

If you're going for XHTML go with:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Show me
If you browse to the next version of Bob's page, you won't notice anything unless you view the source.  Then you'll see the DOCTYPE declaration.



Content managed by the Etomite Content Management System.