Foreword
Hello everyone! This series of articles is written in the process of making this site by Abie. Before Ajie has never produced a website that truly consistent with the Web standard. Now, refer to foreign materials, and record the experience and experience in the process, I hope to help everyone. Ok, let's get started.
first day
Start making a standard site, the first thing is to declare the doctype that meets yourself.
View the home code of this site, you can see the first line is:
Open some standard sites, such as famous Web Design Software Developers Macromedia, Design Master Zeldman's personal website, will find the same code. And other code that meets the standard sites (such as K10K.NET) are as follows:
So what else does this code? Be sure to place it?
What is DOCTYPE
Above these code we call DOCTYPE declaration. DOCTYPE is a discument type, is used to explain what version you use XHTML or HTML.
The DTD (eg, the XHTML1-Transitional.dtd in the above example) is called the document type definition, which contains the rules of the document. The browser explains the identity of your page based on your defined DTD and is displayed.
To establish a standard web page, the DoctyPE statement is an essential key component; unless your XHTML determines a correct Doctype, your identity and CSS will not take effect.
XHTML 1.0 provides three DTD declarations available:
Transitional: Requires very loose DTD, which allows you to continue using HTML4.01 identity (but to comply with XHTML). The full code is as follows:
Strict (strict): requires strict DTD, you cannot use the identity and attributes of any performance layer, such as
. The full code is as follows:
Frameset: DTD designed specifically for the frame page, if your page contains a frame, you need to use this DTD. The full code is as follows:
What kind of DOCTYPE we chose?
Ideally, is of course strict DTD, but for most designers who have just contacted Web standards, the transition DTD (XHTML 1.0 Transitional) is currently ideal (including this site, also transition DTD). Because this DTD also allows us to use the identity, elements, and attributes of the performance layer, it is more likely to pass the W3C code verification. Note: The "identification of the performance layer" said that the TAG that is purely used to control the performance, such as a table, background color identification, etc. In XHTML is used to represent structures, rather than use to implement performance form, the purpose of our transition is to ultimately achieve data and expression.
Take a bit: human model change clothes. The model is like data, the clothes are expressions, models and clothes are separated, so you can change your clothes at will. And in the original HTML4, data and performance are mixed together, and it is very difficult to change the expression. Oh, a bit abstraction, this concept needs we gradually understand in the application process.
supplement
The DOCTYPE statement must be placed at the top of each XHTML document, above all of the code and the identity.
More details Access W3C website