HTML & lt ;! DOCTYPE & gt; tag, htmldoctype tag

Source: Internet
Author: User

HTML <! DOCTYPE> tag, htmldoctype tag

By default, the FF and IE interpretation standards are different. That is to say, if a webpage does not declare DOCTYPE, it will explain the following HTML with the default DOCTYPE. Under the same standard, different browser interpretation models are different. By default, FF and IE interpretation standards are different. That is to say, if a webpage does not declare DOCTYPE, it will explain the following HTML with the default DOCTYPE. Under the same standard, different browsers have different interpretation models. If the Declaration standards are different, you can do it yourself. Learn about web page standards and browser compatibility. You can decide from where to start. However, please know DOCTYPE:

1. What is DOCTYPE?

DOCTYPE is short for Document Type. It is used to specify the XHTML (or HTML) version used on the page. To make a page that complies with the standard, a key component is the DOCTYPE statement. Only when a correct DOCTYPE is determined can the identifier and CSS in XHTML take effect normally.

Ii. DOCTYPE rules

The DOCTYPE statement follows certain rules, which indicate the rule set used by the reader to explain the mark in the document. In the case of Web documents, "reading program" is usually a program such as a browser or a checker, and "rule" is a document type definition (dtd) published by w3c).
Each dtd includes tag, attributes, properties, and other content, which are used to mark the content of the web document. In addition, it includes rules that specify which tags can appear in other tags. Each web Recommendation Standard (such as html 4 frameset and xhtml 1.0 transitional) has its own dtd.

The following are extracted rules 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 FPI is a publicly accessible object or a system resource. PUBLIC default. Publicly accessible objects. SYSTEM resources, such as local files or URLs.
  • -Registration: Specifies whether an organization is registered by the International Standardization Organization (ISO. + Default. The organization name is already registered.
  • -The organization name is not registered. The Internet Engineering Task Group (IETF) and the World Wide Web Association (W3C) are not registered ISO organizations.
  • -Organization: indicates the owner! DOCTYPE declares the name of the group or organization that creates and maintains the referenced DTD, that is, OwnderID. IETF. W3C.
  • -Type: Specifies the public text class, that is, the referenced object type. Default DTD. DTD.
  • -Tag: Specifies the public text description, that is, the unique descriptive name of the referenced public text. The version number can be included later. HTML default. HTML.
  • -Definition: Specify the document type definition.

Frameset framework set documentation.
Strict exclude representative attributes and elements that W3C experts want to gradually remove because style sheets are well-developed.
Transitional contains all content except the frameSet element.

  • -Language: Specifies the public text language, that is, the natural language encoding system used to create the referenced object. The language definition has been written in the ISO 639 language code (two uppercase letters ). EN by default. English.
  • -URL: Specifies the location of the referenced object

To obtain the correct DOCTYPE declaration, the key is to match the dtd with the standards observed in the document. For example, if the document follows the xhtml 1.0 strict standard, the doctype Declaration of the document should reference the corresponding dtd. On the other hand, if the doctype declaration specifies the xhtml dtd, but the document contains html tags of the old style, it is not appropriate. Similarly, if the doctype declaration specifies the html dtd, but the document contains the xhtml 1.0 strict mark, which is also inappropriate.

Iii. DOCTYPE

As shown in the preceding example, there are three DTD (Document Type Definition) declarations in XHTML 1.0: Transitional, Strict, and Frameset ). Here we will introduce them as follows.

1. Transition

A non-strict DTD that allows the use of HTML4.01 Identifiers (in line with xhtml syntax standards) on the page ). The format of the Transition DTD is as follows:

The Code is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

2. Strict

A strict DTD that does not allow the use of any performance Layer identifier and attributes, such as <br/>. The strict DTD syntax is as follows:

The Code is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

3. Framework

A dtd used for a framework page. This DTD is used when the page contains framework elements. The architecture DTD is written as follows:

The Code is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

Using a strict DTD to create a page is of course the most ideal method. However, for Web designers who do not have a deep understanding of Web standards, it is more appropriate to use a transitional DTD. This DTD also allows you to use the identifiers, elements, and attributes of the presentation layer, which is suitable for most website developers.

4. Notes

Nothing special is that the DOCTYPE Declaration must be placed at the top of the XHTML document, even if there are multiple HTML annotation tags on it.

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.