Web page of! DOCTYPE statement and how it works on the web

Source: Internet
Author: User

First, DOCTYPE description-TOP

TheDOCTYPE declaration is an essential part of establishing a standard-compliant web page, and unless your XHTML determines a correct DOCTYPE, your logo and CSS will not take effect, meaning that without this DOCTYPE declaration will cause CSS invalidation -CSS is invalid , especially if no declaration or declaration is incorrect, it will not display properly under standard browser.

DOCTYPE statement
Start making a site that conforms to the standard, and the first thing is to declare the DOCTYPEthat suits your needs.

See a lot of sites developed using XHTML standards, 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, to find the same code.

The code for other standards-compliant sites 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 does this code mean? Must you place it?

What is DOCTYPE
The above code we call the DOCTYPE statement. DOCTYPE is a shorthand for document type, which is used to describe what version of XHTML or HTML you are using.
The DTD (for example, XHTML1-TRANSITIONAL.DTD in the previous example) is called the document type definition, which contains the rules of the document, and the browser interprets the identity of your page according to the DTD you define and shows it.
The DOCTYPE statement is an essential part of establishing a standard-compliant web page, and your logo and CSS will not take effect unless your XHTML determines the correct doctype.

XHTML 1.0 provides three types of DTD declarations to choose from:
* Transition (Transitional): A very loose DTD is required, which allows you to continue to use HTML4.01 's identity (but to conform to XHTML notation), 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 (STRICT): Requires strict DTD, you cannot use any of the presentation layer's identity and attributes, such as <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 (Frameset): specifically for the framework page design used by the DTD, if your page contains a framework, you need to adopt 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 kind of doctype do we choose?
The ideal scenario is of course a strict DTD, but for most of us who are new to Web standards, the transition DTD (XHTML 1.0 Transitional) is the ideal choice. Because this DTD also allows us to use the identity, elements and attributes of the presentation layer, it is also easier to pass the code validation.
Note: The above-mentioned "performance layer identification, attributes" refers to those purely to control the performance of the tag, such as the table for typesetting, background color identification. In XHTML, identities are used to represent structures rather than to implement representations, and the purpose of our transition is ultimately to achieve separation of data and representation.
Make an analogy: the mannequin changes clothes. Models are like data, clothes are expressions, models are separated from clothes, so you can change your clothes. In the original HTML4, the data and performance are mixed together, it is very difficult to change the form of the expression at once. Oh, a bit abstract, this concept requires us to gradually understand the application process.
Add
The DOCTYPE declaration must be placed at the top of every XHTML document, above all code and identities.

By now you can simply abbreviate your doctype,

Put the HTML doctype at the top of the code:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

can be abbreviated as:

      1. <! DOCTYPE HTML>
      2. <html >

Web page of! DOCTYPE statement and how it works on the web

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.