What's a DOCTYPE?

JavaScript and client side scripting.

Moderator: General Moderators

User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

What's a DOCTYPE?

Post by JellyFish »

Why do I need a DOCTYPE or DTD? And most importantly what is it and what does it do?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You ought to try screwing one of them up one of these days. It is amazing what happens.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

Thanks ninja.

Although I don't understand what effect they have. Is there any examples on what changes DOCTYPEs make?

Also, what's strict, transitional and frameset?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Brief rundown...

Strict - Held to the w3c standard for strict syntax and formatting
Transitional (or loose) - allows for backward compatibility with other, older DTD's
Frameset - Frames
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

Could maybe someone gives some examples on what the benefit in having a DTD would be? Maybe that'll clear some confusion.

As of right now, I don't see the purpose for me having one. It doesn't appear to do anything.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

With one, you can get validation. Without one, if memory serves, you'll get an error.

Without a doctype some browsers will have problems (or will display your pages in quirks mode.)

The green check mark is your friend.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

I see.

What's quirks mode, examples?

And I think when you say "The green check mark is your friend" you mean validation?

EDIT: Also, what DOCTYPE should I use, you see I don't understand.

EDIT 2: More precisely, of which should I use: Strict, Transitional or Frameset?
Last edited by JellyFish on Fri Mar 30, 2007 5:16 pm, edited 2 times in total.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

JellyFish wrote:Could maybe someone gives some examples on what the benefit in having a DTD would be? Maybe that'll clear some confusion.

As of right now, I don't see the purpose for me having one. It doesn't appear to do anything.
http://www.w3.org/QA/Tips/Doctype
http://www.w3.org/QA/2002/04/valid-dtd-list.html
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

Okay, which should I use: XHTML or HTML; Strict, Transitional or Frameset?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

How structured do you want to have to code? I use XHTML 1.0 strict. But I hold myself to a very high standard. I would say that folks that like a little bit of flexibility would probably go with an HTML 4.01 Transitional.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

It's the most difficult to conform to the strict doctype. XHTML is something you will need to make your own decision about. There are plenty of articles about it. It's kind of a hot issue for some folks.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

I tried Strict and maybe it was to strict for me. I tried Transitional and it went fine. What's Frameset stand for? Is there somewhere that tells me what Strict, Transitional and Frameset all allow and don't allow? Then maybe I could Choose which is best for me.


BTW every since I got a DTD my page appears the same on all browsers! Except a submit button's width was ridiculously wide and had to set a fixed width to the darn thing. What's up with that?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

we've posted articles that answer all those questions. You can also study the DTDs themselves to see what they allow/don't allow
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I would probably say google for your answers to what the doctypes allow. The w3c.org site is also a very good resource.
Post Reply