Let's Learn Something 2 - The Importance Of Specifying A Doc Type

A Member? Please Login  
type your username and password to login
Date: October 07, 2008, 10:18 AM
247000 members and 145922 Topics
Latest Member: barsikoss
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Webmasters (Moderators: SAM MILLA, uspry1)  |  Let's Learn Something 2 - The Importance Of Specifying A Doc Type
Pages: (1) Go Down Send this topic Notify of replies
Author Topic: Let's Learn Something 2 - The Importance Of Specifying A Doc Type  (Read 135 views)
yawa-ti-de (f)
Let's Learn Something 2 - The Importance Of Specifying A Doc Type
« on: June 30, 2008, 04:35 AM »

As some of you might be aware, the very first line of code in your (X)HTML files should be the doctype.  They come in many flavors.  Here are a few:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Now, I won't bore you with details and would advise you check the w3c site and/or google for more information.  However, as an explanation, I will explain what the above 3 mean and why, in general, specifying a doctype is very important.  Focus on the bold portions please:

#1 and #2 declare that the document will be validated against the strict interpretation of HTML and XHTML respectively.  #3 basically declares that the document will be validated against a loose interpretation of XHTML which means that it will overlook things like using tables while still enforcing things like making sure all tags are opened and closed.   For the most part, sites today are validated against #3 as not all browsers are web standards-compliant.  You can also define your own doctype but that is beyond the scope of this post.

Why is specifying a doctype important?
Because it is important that, especially if you are using a web standards-compliant browser, the document gets "interpreted" properly.  Where no doctype is specified, "funny" things an happen.  This is what is known as the browser entering "quirks mode" which is another way of saying that the browser will fall back to some default mode.  In IE for instance, quirks mode means that your document will default to being displayed as though you were using IE4, not something you would want of course.

Conclusion:
Always specify a doctype.  #3 is preferred as it ensures the minimum required to guarantee that your sites, even without testing, will appear and function properly on a PC, PDA, Screen reader, etc.  I have developed many sites over the years and taken for granted the importance of specifying a doctype only to appreciate it as many years later, not one of my sites has been found wanting on a variety of devices.

Did you find this lesson in learning of any use?  If so, let me know and I will post more from time to time.  Otherwise, I will stop.

Thanks,
tundewoods (m)
Re: Let's Learn Something 2 - The Importance Of Specifying A Doc Type
« #1 on: June 30, 2008, 07:27 AM »

Quote from: yawa-ti-de on June 30, 2008, 04:35 AM

Did you find this lesson in learning of any use?  If so, let me know and I will post more from time to time.  Otherwise, I will stop.

Thanks,


Yes Dear !
You remind me of Instructional Television back in the late 1980's to early 90's from 3 pm- 4pm  Weekdays on NTA network.  Grin
yawa-ti-de (f)
Re: Let's Learn Something 2 - The Importance Of Specifying A Doc Type
« #2 on: June 30, 2008, 12:16 PM »

LOL @tundewoods, funny you mention that.

I actually was thinking of that very show as I was writing this up.  Hmm, perhaps some TV/Radio station would mind experimenting with a show teaching web design/development?

(rubbing chin)
uspry1 (f)
Re: Let's Learn Something 2 - The Importance Of Specifying A Doc Type
« #3 on: June 30, 2008, 03:08 PM »

Great write up, go girl!!!

Go for it creating new youTube-clone TV portal website offering them your "Let's Learn Something" the similar to other poster(Gamine)'s "Design TV Portal" thread.  Grin
yawa-ti-de (f)
Re: Let's Learn Something 2 - The Importance Of Specifying A Doc Type
« #4 on: June 30, 2008, 03:16 PM »

@uspry1

You know, I have actually thought about that.  It's all about finding the time.  But trust me, Lord willing, it is in the works and I will alert you all when I do get one going.

Thanks for the encouraging words.
smartsoft (m)
Re: Let's Learn Something 2 - The Importance Of Specifying A Doc Type
« #5 on: June 30, 2008, 05:08 PM »

same idea but far from your programming stuff  Shocked
OmniPotens
Re: Let's Learn Something 2 - The Importance Of Specifying A Doc Type
« #6 on: July 02, 2008, 01:23 AM »

@yawa
nice one here. I love the explanation. Most webmasters ignore this alot though they are really important. Keep it up.

If you can repackage this, you can come up with something like what "professor teaches" has. It will become an Information product of yours and really, a great deal of ______ you understand  Grin
yawa-ti-de (f)
Re: Let's Learn Something 2 - The Importance Of Specifying A Doc Type
« #7 on: July 02, 2008, 03:17 AM »

@Omnipotens,

Thanks for the compliments.  I am a slow learner and as such when I am teaching others, I like to break it down.

As for the "other stuff", you took the words right out of my mouth.  After part 4 of this series, I am going to put these and other lessons in an E-book and offer it for sale.

@All
Stay tuned for details.
 Must Read For All Webmasters/website Owners  Free Ebook Creator Software   Iasca,cism,cisa And Co.  Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 
Google
 
Web www.nairaland.com
Sections: TV/Movies (2) Music/Radio (2) Celebrities Job Talk Jobs/Vacancies (2) Career Talk Romance Books Politics Sports Fashion Travel
Health Schooling Religion General(2) Business Webmaster Programming Computers Phones Cars & Trucks

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.