Solved

Need explanation on why I need a DTD

Posted on 2000-05-06
3
165 Views
Last Modified: 2013-11-19
Can someone explain to me the advantages of using a DTD (Document Type Declaration)?
Do I need to go back to all of my old web pages and add this?
What is it supposed to do FOR my web pages or TO the web browser?
What happens if I don't have one?
Which numeric version should I use?
When I try to verify HTML at web sites, I am frequently told that the web page has problems even though it works, why?
0
Comment
Question by:sduell
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
shlomoy earned 50 total points
ID: 2785214
A document type definition (DTD) is a specific definition that follows the rules of the Standard Generalized Markup Language (SGML), and in your case, of XML. A DTD is a specification that accompanies a document and identifies what the funny little codes (or
markup) are that separate paragraphs, identify topic headings, and so forth and how each is to be processed. By mailing a DTD with a document, any location that has a DTD "reader" (or "SGML compiler") will be able to process the document and display or print it as intended. This means that a single standard SGML compiler can serve many different kinds of documents that use a range of different markup codes and
related meanings. The compiler looks at the DTD and then prints or displays the document accordingly.

As a matter of fact, the document you are looking at is coded in a particular DTD called HTML.
In this case, the "compiler" or document handler is your Web browser which is designed to handle text documents encoded with HTML tags. (Other programs could be developed that would handle HTML and other DTDs as well.)

IBM and many large and small corporations are converting documents to SGML, each with its own company document type definition or set of definitions. For corporate intranets and extranets, the document type definition of HTML provides one new "language" that everyone can format documents in and read universally.

---------------------------------------

And now, to your questions:

In case you use HTML, no you don't really need a DTD.

In case you use XML, You probably do.

The DTD tells the probram which parses your document (a browser, for example) how to understand the code (HTML for example).

In case you don't have a DTD, you count on the parser on the user's side to be able to "guess" the DTD you use. In the case of HTML, all browsers know to guess that your HTML pages use the HTML DTD. In case you use other type of XML, the guessing wouldn't probably be good.

The numeric version of the DTD really depends on the type of code you write. in case HTML is involved, version 3.2 or 4.0 are the latest.
An example of a DTD decleration for using HTML 3.2:
<!doctype html public "-//W3C//DTD HTML 3.2//EN">

Most browsers tend to understand even BADLY WRITTEN HTML documents.
Reason is, HTML doesn't have really to be "by the rules" (according to the DTD), and browsers do a rather good job, understanding even bad HTML files.
Hopefully, using HTML 4.0 and newver versions of HTML, using a DTD decleration would be a must, hence forcing people to write VALID HTML DOCUMENTS.

I hope this answers all your questions.
0
 
LVL 2

Author Comment

by:sduell
ID: 2785399
Thank you.
0
 
LVL 8

Expert Comment

by:shlomoy
ID: 2785415
You are welcome
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to count occurrences of each item in an array.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now