/    Sign up×
Community /Pin to ProfileBookmark

Can someone please give me a brief guide to what DOCTYPEs are for and how I should specify one for my web pages. Also, how do I choose which DOCTYPE to use ?

I am using PHP/MySQL to build my site, will this have any effect on the choice of DOCTYPE ?

Thanks

to post a comment
Full-stack Developer

13 Comments(s)

Copy linkTweet thisAlerts:
@ExuroJul 24.2003 — 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:

http://htmlhelp.com/tools/validator/doctype.html

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:

http://validator.w3.org/
Copy linkTweet thisAlerts:
@pyroJul 24.2003 — This is a very nice article: http://www.alistapart.com/stories/doctype/
Copy linkTweet thisAlerts:
@RoddersauthorJul 24.2003 — Thank you both.

I will check out those articles this evening.
Copy linkTweet thisAlerts:
@CharlesJul 24.2003 — [font=georgia]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 "™" 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.[/font]
Copy linkTweet thisAlerts:
@dolphindanceSep 10.2003 — 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:

[URL=http://www.dolphindancephotography.com/home.htm]http://www.dolphindancephotography.com/home.htm[/URL]

this is a mock page but i've tried all different types... am i missing something? thanks
Copy linkTweet thisAlerts:
@pyroSep 11.2003 — What seems to be your problem?
Copy linkTweet thisAlerts:
@dolphindanceSep 11.2003 — when you go to my page [URL=http://www.dolphindancephotography.com/home.htm]http://www.dolphindancephotography.com/home.htm[/URL] 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!
Copy linkTweet thisAlerts:
@spufiSep 11.2003 — [i]Originally posted by dolphindance [/i]

[B]when you go to my page [URL=http://www.dolphindancephotography.com/home.htm]http://www.dolphindancephotography.com/home.htm[/URL] 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! [/B]
[/QUOTE]


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.
Copy linkTweet thisAlerts:
@dolphindanceSep 11.2003 — 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.
Copy linkTweet thisAlerts:
@Khalid_AliSep 11.2003 — 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
Copy linkTweet thisAlerts:
@pyroSep 11.2003 — Yep, with short tags enabled in the php.ini file, you will have to use one of these two things:

You can just define your content type with this line (which is my favorite way of doing it):

&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;

With the above way, you will also avoid IE6 going into quirks mode when it runs across the XML prolog.

Or, if you like to use the XML prolog, you can use this:

[code=php]<?php echo "<?xml version="1.0" encoding="iso-8859-1"?".">"; ?>[/code]

Note to Khalid -

If you want your pages to work as is, just turn off short tags in your php.ini file. That should do it... ?
Copy linkTweet thisAlerts:
@spufiSep 11.2003 — 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.
Copy linkTweet thisAlerts:
@Khalid_AliSep 11.2003 — [i]Originally posted by spufi [/i]

[B]

I just took it out because it does still validate without it. [/B]
[/QUOTE]


Thanks for response,however,you seem to overlook the point, that is you have to use a work around to make it work....
×

Success!

Help @Rodders spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...