What is doctype?

Source: Internet
Author: User

Doctype is short for document type. It is used to describe the XHTML or html version you use in web design.

To create a standard web page, the doctype Declaration is an essential part. Your logo and CSS will not take effect unless your XHTML determines a correct doctype.

Doctype Declaration

Start to make a site that meets the standards. The first thing is to declare the doctype that meets your needs.

View many websites developed using the XHTML standard. The first line is:

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Open some standards-compliant websites, such as Macromedia, a famous web design software developer, and taoba.Code.

The code for other websites that comply with the standards is as follows:

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 frameset // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

So what do these codes mean? Are you sure you want to place it?

What is doctype?

The above code is called the doctype declaration. Doctype is short for document type. It is used to describe the XHTML or html version you are using.

The DTD (such as the xhtml1-transitional.dtd in the above example) is called the document type definition, which contains the document rules, the browser according to your definition of the DTD to explain your page identity and display.

To create a standard web page, the doctype Declaration is an essential part. Your logo and CSS will not take effect unless your XHTML determines a correct doctype.

XHTML 1.0 provides three types of DTD declarations:

* Transitional: a very loose DTD that allows you to continue using the html4.01 identifier (but in line with XHTML). 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">

* Strict: a strict DTD. You cannot use any identifier or attribute of the performance layer, for example, <br>. 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">

* Framework: 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">

What doctype should we choose?

The ideal situation is of course a strict DTD, but for most of our designers who are new to web standards, the transitional DTD (XHTML 1.0 transitional) is currently the ideal choice. Because this DTD also allows us to use the identifier, element, and attribute of the presentation layer, it is easier to pass W3C code verification.

Note: The "presentation layer identifier and attribute" mentioned above refers to the tags purely used to control the presentation, such as the table used for typographical layout and background color identifier. In XHTML, identifiers are used to represent structures rather than representations. Our purpose of transition is to ultimately separate data from representations.

For example, a human model changes clothes. Models are like data. clothes are the form of representation. Models and clothes are separated so that you can change clothes at will. In html4, data and performance are mixed, and it is very difficult to change the form at one time. It's a bit abstract. We need to gradually understand this concept in the application process.

Supplement

The doctype Declaration must be placed at the top of each XHTML document, on top of all codes and identifiers.

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.