1st days: What kind of DOCTYPE to choose
Hello everyone! This series of articles is based on the production process of this site by Alibaba Cloud. Alibaba Cloud has never created a website that truly complies with web standards. Now, I am referring to foreign materials and recording my experiences and experiences. I hope this will be helpful to you. Okay. Let's get started.
Day 1
Start to make a site that meets the standards. The first thing is to declare the DOCTYPE that meets your needs.
View the original code on the home page of this site. The first line is displayed:
Open some standards-compliant websites, such as Macromedia, a well-known web design software developer, and Zeldman, a design master, to find the same code. The code for other standard websites (such as k10k.net) is as follows:
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: requires a very loose DTD, which allows you to continue using the HTML4.01 logo (but it must conform to the xhtml syntax ). The complete code is as follows:
- Strict: a Strict DTD is required. You cannot use any identifier or attribute of the performance layer, such
. The complete code is as follows:
- 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:
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 an ideal choice (including this site, is also a transitional DTD ). 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.
For more details, visit the W3C website.