Solved

Need explanation on why I need a DTD

Posted on 2000-05-06
3
172 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

707 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