The doctype gives some basic information on the content of your page. The information it finds there helps the browser to interpret your page correctly, although most sites seem to work fine without them. Here's a nice article on choosing a Doctype for your site:
Using PHP an MySQL shouldn't make any difference in your doctype since they're both server-side. But after you've chosen your doctype and placed it into your webpage you should run it through W3C's validation service to check for errors:
As someone who has written a DTD or two let me fill in a few holes left by those articles, a DOCTYPE does three things:
1) As mentioned, it tells the browser that you know what you are doing;
2) It tells validators what version of HTML you are using;
3) It defines the entities.
One above is discussed in one of those articles. As to two, the different versions of HTML have very different rules and it is a important to keep them straight as it is difficult to remember what rules go with what HTML version you are using. And everybody makes mistakes. It is very important to always run your page through a validator and the validator cannot work without knowing what HTML version you are using. The entities are things like "&trade;" and they are defined in the DTD and can be defined in the DOCTYPE file. Browser support is iffy to say the least, but you can define your own entities and you can even use them to include the contents from other files.
Most of that stuff is built into the browser and you don't want to go about playing with entities unless you are using XML.
But it is important to use the DOCTYPE that corresponds to the version of HTML that you are using.
HTML 3.2 is the old kind of HTML. It's what most people think of when you say HTML. Anything written in HTML 3.2 will work on all graphical browsers.
HTML 4.01 Strict is the gold standard. Anything written in HTML 4.01 will in all browsers, be the graphical or non-graphical. This is the one all good web author's use.
HTML 4.01 Transitional includes all of 3.2 and all of 4.01 Transitional. 4.01 Strict relies upon CSS for layout and presentation. The idea was to allow web authors to create a page that like 4.01 Strict documents would work on all browsers but that like 3.2 documents would look good on all graphical browsers. In practice web authors use it to get away with sloppy HTML, ending up with documents that don't work on all graphical browsers and don't work on non-graphical browsers. It's best to not use the transitional DTD.
HTML 4.01 Frameset is for framesets and it includes all of the 4.01 Transitional DTD for your NOFRAMES element. This one has everything including the kitchen sink.
XHTML 1.0 Strict, Transitional and Frameset are just the HTML 4.01 DTDs in XML.
XHTML 1.1 is HTML 4.01 Strict in XML.
“The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
—Tim Berners-Lee, W3C Director and inventor of the World Wide Web
i'm opening up this discussion again be/c i'm having many problems with doctypes. i was told i need doctypes and i inserted one and this is what it did: http://www.dolphindancephotography.com/home.htm
this is a mock page but i've tried all different types... am i missing something? thanks
Last edited by dolphindance; 09-10-2003 at 06:39 PM.
when you go to my page http://www.dolphindancephotography.com/home.htm you can see my navigation bar a contact info box and a bunch of photos pile up in the left top corner. the bar and contact box are supposed to be on the bottom, and the photos on top of the different shapes at top. it's all whacked out - and that only happened when i added the doctype.
Originally posted by dolphindance when you go to my page http://www.dolphindancephotography.com/home.htm you can see my navigation bar a contact info box and a bunch of photos pile up in the left top corner. the bar and contact box are supposed to be on the bottom, and the photos on top of the different shapes at top. it's all whacked out - and that only happened when i added the doctype.
thanks for your attention!
I just wanted to say I am still working on fixing your problem, but I hit a snag with the graphics. I did post a thread in the graphics forum about it. I also now see the menu bar, so that will be easy to handle since I use the same kind of one for my own site.
hey, thanks! i still don't understand why doctypes won't work for my site. i've also made many changes to the site - the engineers are still trying to figure out my server problem so they've had me change a lot of the file names. well...must admit, i had names with spaces and stuff that i didn't know about thanks for all your help.
Since we are talking about XHTML,and there was a PHP/MySQL part to this thread as well, here is a very serious problem???? with PHP I noticed( or since I am a newbie when it comes to php,I might not know the answer.. )
If you use an XHTML page that starts with
<?xml version="1.0"?> tag, php does not load such page....f**king crap....you have to remove those tags....by default all of my pages have this statement and strict XHTML doctype,I was bummed to find out that I had to remove that from all of my pages to work in PHP
Without a Doctype, a browser goes into quirks mode, and the browser does it's best to figure out what version of HTML to you are using. I can't remember what the defaults are for quirks mode, but I know Netscape goes back a ways. This means your site would be read based on a old broweser that may not know how to handle some of the code you used even if it was valid. I maybe wrong in this, but I'm sure somebody will correct me if I am. I do know that having invalid code and a Doctype leads to funny things happening.
Khalid Ali, since I use XHTML for my site, I did run into a problem with using <?xml version="1.0"?> I just took it out because it does still validate without it.