jsp html page DOCTYPE

Declare the DOCTYPE that meets your needs.

Looking at the original code, you can see that the first line is:

Open some standards-compliant sites, such as the personal website of the famous web design software developer Macromedia and design master Zeldman, and you will find the same code. The codes of other sites that meet the standards (such as k10k.net) are as follows:

So what do these codes mean? Must it be placed?

What is DOCTYPE

The above codes are called DOCTYPE declarations. DOCTYPE is an abbreviation of document type, which is used to indicate what version of XHTML or HTML you are using.

The DTD (for example, xhtml1-transitional.dtd in the above 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 displays it.

To build a standard-compliant web page, the DOCTYPE declaration is an essential key component; unless your XHTML determines a correct DOCTYPE, neither your logo nor CSS will take effect.

XHTML 1.0 provides three DTD declarations to choose from:

Transitional (Transitional): requires a very loose DTD, which allows you to continue to use the HTML4.01 logo (but to comply with the wording of xhtml). The complete code is as follows:

Strict (Strict): requires strict DTD, you can not use any presentation layer logo and attributes, for example
. The complete code is as follows:

Frame (Frameset): A DTD specifically designed for frame pages. If your page contains frames, you need to use this DTD. The complete code is as follows:

What DOCTYPE do 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 the ideal choice (including this site, which is also a transitional DTD). Because this DTD also allows us to use the logo, elements and attributes of the presentation layer, it is easier to pass W3C code verification.

Note: The "labels and attributes of the presentation layer" mentioned above refer to tags that are purely used to control performance, such as tables used for typesetting, background color identification, etc. In XHTML, the mark is used to express the structure, not to realize the form of expression. The purpose of our transition is to finally realize the separation of data and performance.

An analogy: the mannequin changes clothes. Models are like data, and clothes are forms of expression. Models and clothes are separated, so you can change clothes at will. In the original HTML4, data and performance are mixed together, and it is very difficult to change the form of expression at once. Haha, it's a bit abstract, this concept needs us to gradually understand in the application process.

supplement

The DOCTYPE declaration must be placed at the top of every XHTML document, above all codes and logos

Reprinted at: https://blog.51cto.com/jackielieu/1201004

Guess you like

Origin blog.csdn.net/qq_41076577/article/details/108168554