PDA

View Full Version : Need for DOCTYPE declaration



mpr
May 10th, 2006, 02:34 PM
I'm wondering if anyone can answer 'why' to this one.

According to the livedocs on Macromedia's section of Dreamweaver, there must be a DOCTYPE declaration in the document prior to the root element, and the declaration must reference one of the three Document Type definition (DTD) files for XHTML (strict, transitional, or frameset).
What it doesn't say is why.
Nor does the W3 consortium say anything about it, other than that it must be in the page. No real (or clear) reason why.

I have tried publishing pages without this declaration and have had no problem.

bwh2
May 10th, 2006, 02:51 PM
http://www.alistapart.com/stories/doctype/

a DOCTYPE basically tells the browser which version of (x)html you're using, so the browser knows how to interpret your page. by including a DOCTYPE, you're helping the browser. as more browsers are developed, the more important DOCTYPE is going to be because interpretations will vary as will default DOCTYPEs.

just not not closing certain tags will work, publishing without a DOCTYPE will work, but it's not ideal.

mpr
May 10th, 2006, 03:11 PM
Granted, it's important.
However, I have noticed an abundance of problems with javascript when it comes to certain browsers. This all started when I tried to add the famous javascript "scrollbar colour" code for my browser of choice, Opera. Needless to say it didn't work. If you've ever tried this code just about every page you find this code on will say that it "only works for IE 5+" or something to that effect. A quick search for answers to the question "how do I get it to work in Firefox or Opera?" will take you to countless forums where the typical response is "it doesn't work that I know of..." with various reasons why.
So...
What I did was get rid of the DOCTYPE info in the html tag and low-n-behold...most of the javascripts that never worked in anything other than IE now work with no problems. Like I said, I've even published this on the web and tested it with newer and older versions of the 3 major browsers and it seemed to work just fine.

I guess I'm just trying to figure out if there is something that I'm not seeing here that will cause problems for me in the future. I'm certain that browsers are rather complex now, let alone 5 years ago but so far, no problems yet! :block:

bwh2
May 10th, 2006, 03:35 PM
have you tried using different DOCTYPEs or just stuck with one?

mpr
May 10th, 2006, 04:08 PM
I've tried the three main ones (strict, loose, frameset) and nothing seemed to work until I just ripped the whole thing outta there.