What is DTD?

Source: Internet
Author: User

[Abstract]

DTD is the English document type definition, which means "document class definition" in Chinese ". DTD has two tasks: on the one hand, it helps you write legalCodeOn the other hand, it allows the browser to display the code correctly. Maybe you will ask them if they have such capabilities?

If you are a Web Builder, you will clearly know that the basic structure of an HTML document can be divided into two main parts;

 
<HTML>
<Head>
Header information
</Head>
<Body>
Visible content
</Body>
</Html>

You are not familiar with the above Code. But do you know that the following code is both correct and wrong?

<P align = "center"> This is a center section </P>

In XHTML, tags are case-sensitive and the above Code is meaningless. It can be a center section in HTML. How does the browser handle this situation? Does the browser think that you are writing HTML and then display it as a center section? If you write XHTML, it will be a piece of unprintable code! How does the browser know what markup language you are using and treat this code correctly?

This is the work of DTD. A dtd should be placed in the first line (including blank spaces) of each document. In this way, your DTD can tell the browser what markup language is used. In general, if you write the correct code and have a suitable DTD, the browser will display your code according to W3C standards.

If you do not use a DTD, it will be difficult to predict how your code is displayed in the browser. Different display effects can be achieved only in the same browser. Even if your webpage is very bright and you do not use a DTD, your efforts are in vain. Therefore, a DTD is essential.

If you are creating a webpage, your DTD should reflect the markup language you are using. The following is a DTD list, one of which should be used.

  • XHTML 1, 1.1

    <! Doctype HTML public "-// W3C // dtd xhtml 1.1 // en" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  • Xhtml1.0 strict DTD(Strict document class definition): a strict DTD is required. You cannot use performance identifiers and attributes, and use them with CSS. The complete code is as follows:
    <! Doctype HTML public "-// W3C // dtd xhtml 1.0 strict // en"
    Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>

     

  • Xhtml1.0 transitional DTD(Transition document class definition): requires a very loose DTD, which allows you to continue to use the html4.01 logo (but must conform to the XHTML syntax ). The complete code is as follows:
    <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en"
    Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>

     

  • Xhtml1.0 frameset DTD(Framework set document class definition): a dtd designed specifically for the Framework page. If your page contains a framework, you need to use this DTD. The complete code is as follows:
    <! Doctype HTML public "-// W3C // dtd xhtml 1.0 frameset // en"
    Http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd>

  • HTML 4.01 strict DTD(Strict document class definition) cannot contain outdated elements (or attributes) and framework elements. For documents that use this type of DTD, use the following document declaration:
    <! Doctype HTML public "-// W3C // dtd html 4.01 // en"
    Http://www.w3.org/TR/html4/strict.dtd>
  • HTML 4.01 transitional DTD(Transition document class definition) can contain outdated elements and attributes, but cannot contain framework elements .. For documents that use this type of DTD, use the following document declaration:
    <! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en"
    Http://www.w3.org/TR/html4/loose.dtd>
  • HTML 4.01 frameset DTD(Framework set document class definition ). It can contain outdated elements and framework elements .. For documents that use this type of DTD, use the following document declaration:
    <! Doctype HTML public "-// W3C // dtd html 4.01 frameset // en"
    Http://www.w3.org/TR/html4/frameset.dtd>
  • In HTML 3.2<! Doctype HTML public "-// W3C // dtd html 3.2 final // en">
  • In HTML 2.0<! Doctype HTML public "-// IETF // dtd html 2.0 // en">

 

The following is a legal HTML document.

 
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en"
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<HTML>
<Head>
Header information
</Head>
<Body>
Visible content
</Body>
</Html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.