The first day
When you start making a site that meets standards, the first thing you do is declare the DOCTYPE that meets your needs.
Looking at the original code of the homepage of this website, you can see that the first line is:
"http://www.w3. org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
If you open some sites that meet standards, such as the personal website of the famous web design software developer Macromedia and the design master Zeldman, you will find the same code. The code for other standards-compliant sites (such as k10k.net) is as follows:
So what do these codes mean? Does it have to be placed?
What is DOCTYPE
We call the above codes DOCTYPE declarations. DOCTYPE is the abbreviation of document type and is used to indicate what version of XHTML or HTML you are using.
The DTD (such as xhtml1-transitional.dtd in the above example) is called the document type definition, which contains the rules of the document. The browser will interpret the identity of your page based on the DTD you defined and display it.
To build a standards-compliant web page, the DOCTYPE declaration is an essential and critical component; unless your XHTML determines a correct DOCTYPE, neither your logo nor your CSS will take effect.
The complete code is as follows:
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
Strict: For strict DTD, you cannot use any presentation layer identifiers and attributes, such as
. The complete code is as follows:
Frameset: A DTD specifically designed for frame pages. If your page contains a frame, you need to use this DTD. The complete code is as follows:
What kind of DOCTYPE do we choose? The ideal situation is of course a strict DTD, but for most of us designers who are new to web standards, the transitional DTD (XHTML 1.0 Transitional) is currently the ideal choice (including this site, also uses transitional DTD). Because this DTD also allows us to use presentation layer identifiers, elements and attributes, it is also easier to pass W3C code verification.
Note: The "identification and attributes of the presentation layer" mentioned above refer to those tags that are purely used to control performance, such as tables for typesetting, background color identification, etc. In XHTML, tags are used to represent structures, not to achieve presentation. The purpose of our transition is to ultimately separate data and presentation.
For example: a mannequin changes clothes. The model is like data, and the clothes are the form of expression. The model and the clothes are separated, so you can change clothes at will. In the original HTML4, data and presentation were mixed together, and it was very difficult to change the presentation form at once. Haha, it's a bit abstract. This concept needs to be gradually understood during the application process.
Supplement
The DOCTYPE declaration must be placed at the top of every XHTML document, above all code and markup.
For more details, please visit the W3C website
The above is the first day of building a website using Web standards: what kind of DOCTYPE content to choose. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!