Key points for web standard sites (reposted)

xiaoxiao2021-03-06  101

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. ====================================

After DOCTYPE declares, the next code is:

Usually our HTML4.0 code is just , what is "XMLns" here?

This "xmlns" is an abbreviation of XHTML Namespace called "Name Space" declaration. What is the role of name space? Abie's understanding is:

Since XML allows you to define your own identity, your defined identity and other people defined the same identity, but represents different meaning. Errors are easily generated when file exchange or sharing. In order to avoid this error, XML uses a namespace declaration, allowing you to identify your identity through a URL. E.g:

Xiao Wang and Xiao Li defined a logo, if the namespace of Xiao Wang is "http://www.xiaowang.com", Xiao Li's namespace is "http://www.xiaoli.com" Then, when two documents exchange data, it will not confuse the ID because it belongs to different namespaces.

More popular explanations are: The namespace is a tag to document, tell others, this document is who is. Only this "who" has used a website instead.

XHTML is an identifier language of HTML to the XML transition, which needs to meet the XML document rules, so you need to define the namespace. Also because XHTML1.0 cannot be customized, it is the same space, which is "http://www.w3.org/1999/xhtml". If you still don't understand, don't matter, we can use the code at present.

LANG = "GB2312", specify your document Simplified Chinese. ==============================================

The third step is to define your language code, like this:

In order to be properly explained by the browser, all XHTML documents must declare the encoding language they use, we generally use GB2312 (Simplified Chinese), making multi-language page, can also use unicode, ISO-8859-1 Wait, define it according to your needs.

It is usually defined in this way. However, it is necessary to add that the XML document is not such a definition of language encoding, and the XML definition method is as follows:

You can see similar statements in Macromedia.com's homepage code, which is also a definition method for W3C recommendation. Then why don't we use this method directly? The reason is that some browsers are not perfect for standard support, and such definition methods cannot be correctly understood, such as IE6 / Windows. So under the current transition scenario, we still recommend using Meta mode. Of course, you can write two ways.

See the source code of this site, you will find that the language coding definition is more

This is written for the old version of the browser to ensure that all browsers can explain the page correctly.

Note: At the end of the statement, you see a slash "/", which is different from our previous HTML 4.0 code. The reason is that the XHTML grammar rules require that all identities must have started and end. For example, and ,

and , etc. For unpaired identifiers, require the last plus a space, then follow one "/". E.g.
written
, written , the reason is to avoid the code spaces together browsers do not recognize. ================================================================================★

Designing websites with a Web Standards, the method of transition is mainly using XHTML CSS, and the CSS style sheet is essential. This requires all web designers to master CSS, if you are not used in previous, then you will start learning. To make a Web-standard website, CSS is not designed with a beautiful page.

In fact, all the places of performance need to be implemented with CSS. We used to locate and layout with table, and now you have to use DIV to locate and layout. This is a change in thinking, and some are not used to it. Oh, any change will have resistance, in order to enjoy the "benefit" brought, give up some old traditional practice is worth it.

External calling style sheet

Before, we usually use a style sheet using 2 methods:

Page Follow: It is to write a style sheet directly on the head area of ​​the page code. Similar to this: