What is doctype? What does it do for webpages?

Source: Internet
Author: User
Tags color identifier

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 sites, such as the famous web design software developer Macromedia, Web Tao bar, will find the same 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.

 

 

 

The Declaration at the beginning of the HTML/web/'> webpage may be of little concern to us. Next I will write down my understanding based on the online materials. please correct me more.

Some website source code starts

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

Some website source code starts

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

The beginning of the source code of the two web pages is basically the same, the former is more than the latter's html xhtml Web Page code this page has a lang = "UTF-8"

  1. What is doctype?

Doctype is short for document type. It is used to describe the XHTML or html version you are using.
HTML public "-// W3C // dtd xhtml 1.0 transitional // en"
Indicates that the webpage complies with W3C // standard. The language is en, the format is dtd xhtml, And the XHTML version is 1.0.

  2. What is a DTD?

Document Type Definition)
It contains the document rules, and the browser will explain the logo of your page according to your defined DTD and display it.

(1) Transition type (Transitional)
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
(2) Strict)
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 strict // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
(3) Framework (frameset)
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 frameset // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
The selection of DTD will be followed by post instructions.

  3. What is xmlns?

"Xmlns" is the abbreviation of XHTML namespace, called "namespace" Declaration
Because XML allows you to define your own identifiers, the identifiers you define may be the same as those defined by others, but they indicate different meanings. Errors may occur when files are exchanged or shared. To avoid such errors, XML uses namespace declarations, allowing you to identify your identity through a Web site.

  4, xmlns = "http://www.w3.org/1999/xhtml" after the Web site can be changed to another?

XHTML is the identifier language for the transition from HTML to XML. It must comply with XML document rules, so you also need to define the namespace. Because xhtml1.0 cannot customize the identity, so its namespace is the same, is the http://www.w3.org/1999/xhtml

  5. html Lang attributes

This attribute is often used in HTML tags to indicate that the entire document (File) uses a certain language, or in an XHTML tag.
<HTML xmlns = "http://www.w3.org/1999/xhtml" XML: lang = "ZH-CN">
Zh-CN indicates that the XHTML document uses Chinese en to indicate that the XHTML document uses English
The XML: lang attribute allows the search engine to understand the language in which your page is used. The search engine can classify pages by language or start some automatic translation systems. the XML: lang attribute can also enable the typographical tool to know the language in which your page is used, so that the corresponding typographical tool can switch between punctuation marks, conversion formats, and other operations.
In the original webjx code, is lang = "UTF-8" correct? My understanding is that UTF-8 is an encoding format, and the lang attribute value should be a string that represents the language type. Which teacher should explain it.

From: http://blog.csdn.net/ado1025/article/details/5466665

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.