DTD

  • Cae
  • Expert
  • Expert
  • User avatar
  • Posts: 734

Post 3+ Months Ago

ATNO/TW: in another thread you said:

Quote:
then define "DTD", and give it to me in terms of HTML and XHTML


i followed the links you posted, and i got completely lost... ive never included it in any of the sites/pages ive made... what is the purpose of DTD? just curious...
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Document Type Declorations, in short are are for standards. Some browsers like the 500lb gorilla (MS Internet Explorer) generally look at theese declorations and think, "Well it says it's an XHTML document so i'll get ready to parse it as an XHTML document, but i'll keep my eyes open just in case there's somthing in here that doesn't follow the standard." So the browser looks into it's bag of tools, gets the XHTML parsing tools and some other tools "just in case" this means the browser has to carry some extra weight in the form of RAM or other resources.

Now if everyone follows standards and declares what form of standards they are following in thier pages DTD then browsers don't have to carry this extra weight, the browsers can simply look an the DTD, grab only the tools that it will need for that DTD and parse the page accordingly, resulting in less resources needed and faster overall performance.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Excellent description, joebert.

Calendae,
Webopedia also gives a very good definition:
http://www.webopedia.com/TERM/D/DTD.html

In essence, every browser needs a Doctype Definition to understand what to do with the page and the rules it should follow in parsing it. When you do not include a DTD as you indicated in your post, the browser looks to it's internal one. This, in some cases, is what frustrates a lot of new webmasters, because they can't figure out why pages that look just fine in IE look out of whack in other browsers. IE's internal DTD is somewhat different than Netscape/Mozilla and others.

When people do use a DTD the most common one I see them use is this:
Code: [ Select ]
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">


This brings us a step closer to coding to standards as it clearly defines for the browser that this page is a HTML 4.0 Transitional document. However, it does not specify which DTD to use, therefore the browser once again defaults to it's internal DTD.

The correct DTD for HTML 4.0 transitional is:
Code: [ Select ]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
  2. "http://www.w3.org/TR/REC-html40/loose.dtd">


Notice now we have a reference link to the W3 DTD for HTML 4.0 Loose. HTML doctypes come in 3 flavors - Strict, Loose, and Frameset. When a webmaster chooses Strict, then the page must be coded exactly to the definitions of the DTD and follow it's rules to the letter in order to be valid. Loose includes depricated elements that are not necessarily part of the current standard, but allows webmasters to transition to the new standards, while still using some older code. Frameset, obviouly should be used for frame pages.

In addition, the HTML4.0 Doctype declaration posted above is outdated as the current HTML standard is 4.1. XHTML has a similar set of three declarations similar to above. W3Schools gives an excellent tutorial on the XHTML Doctypes: (Added note - in XHTML Transitional is used instead of Loose)
http://www.w3schools.com/xhtml/xhtml_dtd.asp

Hope that helps you understand it better.
  • Cae
  • Expert
  • Expert
  • User avatar
  • Posts: 734

Post 3+ Months Ago

mmmkay, thanx, that makes sense... guess ill have to go and paste that into all my pages now... :P
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

You may want to get aquainted with this link while your inserting DTDs into all your pages.

http://validator.w3.org/

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 79 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.