Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,155,809 members, 7,827,977 topics. Date: Tuesday, 14 May 2024 at 08:32 PM

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

Nairaland Forum / Science/Technology / Webmasters / Let's Learn Something 2 - The Importance Of Specifying A Doc Type (936 Views)

Let's Learn PHP / Let's Learn Something 5: Flash Abuse / Let's Learn Something: Website Optimization (2) (3) (4)

(1) (Reply) (Go Down)

Let's Learn Something 2 - The Importance Of Specifying A Doc Type by yawatide(f): 4:35am On Jun 30, 2008
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,
Re: Let's Learn Something 2 - The Importance Of Specifying A Doc Type by tundewoods(m): 7:27am On Jun 30, 2008
yawa-ti-de:


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
Re: Let's Learn Something 2 - The Importance Of Specifying A Doc Type by yawatide(f): 12:16pm On Jun 30, 2008
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)
Re: Let's Learn Something 2 - The Importance Of Specifying A Doc Type by uspry1(f): 3:08pm On Jun 30, 2008
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
Re: Let's Learn Something 2 - The Importance Of Specifying A Doc Type by yawatide(f): 3:16pm On Jun 30, 2008
@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.
Re: Let's Learn Something 2 - The Importance Of Specifying A Doc Type by smartsoft(m): 5:08pm On Jun 30, 2008
same idea but far from your programming stuff shocked
Re: Let's Learn Something 2 - The Importance Of Specifying A Doc Type by OmniPotens(m): 1:23am On Jul 02, 2008
@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
Re: Let's Learn Something 2 - The Importance Of Specifying A Doc Type by yawatide(f): 3:17am On Jul 02, 2008
@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.
Re: Let's Learn Something 2 - The Importance Of Specifying A Doc Type by Nmeri17: 8:45am On Nov 26, 2014
guys abeg my chrome is HTML5 compatible but the instant I specify doctype html before my site head, it doesn't recognize the CSS anymore. what could be wrong
Re: Let's Learn Something 2 - The Importance Of Specifying A Doc Type by Adesege(m): 1:44am On Nov 27, 2015
Nmeri17:
guys abeg my chrome is HTML5 compatible but the instant I specify doctype html before my site head, it doesn't recognize the CSS anymore. what could be wrong

Hello,

I will make an assumption you are declaring a html4 doc type.

If my assumption is right, then you are experiencing a cross platform issue.

The reason is because html4 or lower declares some default values for some css properties while html5 does not.

When migrating from older versions of a platforms/softwares, be sure to read the backward compatibility for detailed explanations on changes made.

For example, html4 declares a default padding/paragraph from the start of a document, while html5 does not.

So if there is any funny behaviour, know that something has changed.

In between, Yawatide, nice seeing a female programmer with passion. Do you write programs or you just code?


Best regards,
Adesege.

(1) (Reply)

How To Test Formmail In A Local Apache Server / How To Design Advance Sites Like Facebook,jambonline Coaurse / How To Start Bulk Sms Business - Cheap & Reliable Api Interfaces?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 23
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.