DOCTYPE html is important

韦小宝
Release: 2017-11-23 09:44:49
Original
1278 people have browsed it

By default, the interpretation standards of FF and IE are different. That is to say, if a web page does not declareDOCTYPE, it will interpret the following with the defaultDOCTYPEHTML. Under the same standard, the interpretation models of different browsers are different. If the declaration standards are different, I don't need to tell you, just think about it yourself. Learn web standards and browser compatibility. You decide where to start. However, please understandDOCTYPE

## 1. What is DOCTYPE

DOCTYPE is the abbreviation of Document Type. In the page, it is used to specify the version of XHTML (or HTML) used by the page. To create standards-compliant pages, an essential and key component is the DOCTYPE declaration. Only by determining a correct DOCTYPE can the logo and CSS in XHTML take effect normally.

2. The rules of DOCTYPE

The writing method of DOCTYPE declaration follows certain rules, which indicates what set of rules the reading program should use to interpret the document mark in . In the case of Web documents, the "reader" is usually a program such as a browser or a validator, and the "rules" are the rules contained in a document type definition (dtd) published by the W3C.

Each dtd includes tags, attributes, properties, etc., which are used to mark the content of web documents; it also includes some rules that specify which tags can appear in which other tags. Each web recommendation standard (such as HTML 4 Frameset and XHTML 1.0 Transitional) has its own DTD.

Syntax:

HTML Top-Level Element Availability"Registration//Organization//Type Tag//Definition Language""URL"

Possible Values:

- Top-level element: Specifies the type of top-level element declared in the DTD. This corresponds to the declared SGML document type. HTML default. HTML.

- Availability: Specifies whether the Formal Public Identifier (FPI) is a publicly accessible object or a system resource. PUBLIC Default. Publicly accessible objects. SYSTEM System resources, such as local files or URLs.
- Registration: Specifies whether the organization is registered by the International Organization for Standardization (ISO). + Default. The organization name has been registered.
- The organization name is not registered. The Internet Engineering Task Force (IETF) and the World Wide Web Consortium (W3C) are not registered ISO organizations.
Organization: Specify the name of the group or organization responsible for the creation and maintenance of the DTD referenced by the !DOCTYPE declaration, that is, the OwnerID. IETF IETF. W3C W3C.
- Type: Specifies the public text class, that is, the type of object being referenced. DTD default. DTD.
- Tag: Specifies a public text description, a unique, descriptive name for the public text being referenced. A version number can be attached at the back. HTML default. HTML.
- Definition: Specifies the document type definition.
Frameset Frameset document.
Strict excludes all representative attributes and elements that W3C experts want to phase out because the style sheet is already well established.
Transitional contains all contents except frameSet elements.
- Language: Specifies the public text language, the natural language encoding system used to create the referenced object. The language definition has been written as an ISO 639 language code (uppercase two letters). EN default. English.
- URL: Specify the location of the referenced object

In order to obtain the correct DOCTYPE declaration, the key is to make the dtd correspond to the standard that the document follows. For example, assuming that the document follows the xhtml 1.0 strict standard, the document's doctype declaration should reference the corresponding dtd. On the other hand, if the doctype declaration specifies an xhtml dtd, but the document contains old-style html markup, it is inappropriate; similarly, if the doctype declaration specifies an html dtd, but the document contains xhtml 1.0 strict markup , is also inappropriate.

3. What kind of DOCTYPE to choose

As shown in the above example, there are 3 types of DTD (Document Type Definition) declarations in XHTML 1.0 Choose from: Transitional, Strict, and Frameset. They are introduced here as follows.

1. Transitional

A DTD with less stringent requirements that allows the use of HTML4.01 logos in pages (complying with xhtml syntax standards). The transitional DTD is written as follows:

The code is as follows:

"http:/ /www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

2. Strict

A strict DTD that does not allow the use of any presentation layer identifiers and attributes, such as
, etc. The strict DTD is written as follows:

The code is as follows:

"http:/ /www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

3. Frame

A DTD specifically used for frame pages. This DTD is used when the page contains frame elements. The DTD of the framework is written as follows:

The code is as follows:


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset .dtd">

Using strict DTD to create pages is of course the most ideal way. However, for web designers who do not have a deep understanding of web standards, it is more appropriate to use a transitional DTD. Because this DTD also allows the use of presentation layer identifiers, elements and attributes, it is more suitable for most web page developers.

4. Issues that need attention

Nothing special, that is, the DOCTYPE statement must be placed at the top of the XHTML document, even if there are more None of the HTML comment tags work.

It is best to add DOCTYPE to the sample code, otherwise the effect will be different.

Just read this article. Many programming tools are now automatically generated, or generated using shortcut keys.

Related recommendations:

Why use DOCTYPE HTML_HTML/Xhtml_Web page production

Learning about_html/css_WEB-ITnose

##declares that the div height is 100% Problem solving method

The above is the detailed content of DOCTYPE html is important. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!