Home  >  Article  >  Web Front-end  >  HTML tag_html/css_WEB-ITnose

HTML tag_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:04:23922browse

By default, the interpretation standards of FF and IE are different. That is to say, if a web page does not declare a DOCTYPE, it will interpret the following HTML with the default DOCTYPE. 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 get to know DOCTYPE:

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. Rules of DOCTYPE

The writing of DOCTYPE declaration follows certain rules, which indicates what set of rules the reading program should use to interpret the tags in the document. 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 stipulate 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.

Here are the rules taken from the manual:

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, i.e. 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: Specifies the location of the referenced object

In order to obtain a 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 to choose from in XHTML 1.0: Transitional and Strict ) and frame (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:

"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:

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

3. Frame's

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:

"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 multiple HTML comment tags above it will not work.

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

Statement:
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