Solved

Need explanation on why I need a DTD

Posted on 2000-05-06
3
166 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
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.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

895 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

15 Experts available now in Live!

Get 1:1 Help Now