Talk about HTML <! Doctype> Label

Source: Internet
Author: User
Tags basic html page deprecated

A general structure of a basic HTML page, as shown in the following code:

The basic page has, then this page of the label, the browser how to parse it. The HTML structure browser above can only generate DOM tree based on its own understanding. Then, according to the tag inside, the corresponding object and object level relationship can be generated in your own way. If you want to actually render the page, you need to tell the browser what kind of rules to render, if not the browser will be taken for granted.

When the DOCTYPE tag is not introduced, the page is rendered according to the quirks mode (quirks mode), when the page's parsing of the style is done using a browser, because each browser vendor has different parsing forms for each element of the page, causing everyone to have their own samples, Bizarre (as I understand it).
When the DOCTYPE tag is introduced, the page is rendered by parsing each element according to the standard declared by the DOCTYPE label. This time because the standard of the declaration is consistent, the browser in the way the elements are rendered the same, this time the page can be in most browsers to achieve the same layout. This is unified, all follow a standard to go, so this time the page is in the standard mode (strict mode).

How do you switch between these two modes?

The 1th method is to put the page in the appropriate mode by adding and removing doctype.
The 2nd method, in IE, can be switched quickly by switching the document mode.

What is the use of this switch, in fact, no use.
Sometimes IE has a pattern of confusion, you can see the document mode to determine the cause of the bug.
For example, a bug that had been written before in the previous article stating that a comment appeared before the document declaration.

In modern browsers, strange patterns can also be very well parsed.

know the past before we know the future

In HTML4.01, Doctypek declares a reference to the DTD, based on the language standard of SGML. The rules of the markup language of the DTD, which enable the browser to render correctly.
The advent of the HTML5 era is no longer based on SGML, so there is no need to reference a DTD.
Here is a brief introduction to some of the frequently quoted DOCTYPE declarations in HTML4.01.

HTML 4.01 Strict

The DTD contains all the HTML elements and attributes, but does not include the display and deprecated elements (such as font). Frameset not allowed (framesets)

<! DOCTYPE htmlpublic "-//w3c//dtd HTML 4.01//en" "Http://www.w3.org/TR/html4/strict.dtd" >

HTML 4.01 Transitional

The DTD contains all the HTML elements and attributes, including both display and deprecated elements (such as font). Frameset not allowed (framesets)

<! DOCTYPE htmlpublic "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >

HTML 4.01 Frameset

The DTD is equal to the HTML 4.01Transitional. But allow frameset (framesets)

<! DOCTYPE htmlpublic "-//w3c//dtd HTML 4.01 frameset//en" "HTTP://WWW.W3.ORG/TR/HTML4/FRAMESET.DTD" >

XHTML 1.0 Strict

The DTD contains all the HTML elements and attributes, but does not include the display and deprecated elements (such as font). Frameset (framesets) is not allowed. tags must be written in well-formed XML.

<! DOCTYPE htmlpublic "-//w3c//dtd XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >

XHTML 1.0 Transitional

The DTD contains all the HTML elements and attributes, including both display and deprecated elements (such as font). Frameset (framesets) is not allowed. tags must be written in well-formed XML.

<! DOCTYPE htmlpublic "-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

XHTML 1.0 Frameset

The DTD contains all the HTML elements and attributes, including both display and deprecated elements (such as font). But the frameset is allowed (framesets). tags must be written in well-formed XML.

<! DOCTYPE htmlpublic "-//w3c//dtd XHTML 1.0 frameset//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd" >

XHTML 1.1

The DTD is equivalent to XHTML1.0 Strict, but allows models to be added (for example, to provide Ruby support for East Asian languages).

<! DOCTYPE htmlpublic "-//w3c//dtd XHTML 1.1//en" "Http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" >

HTML5 's statement

<! Doctypehtml>

is not the eyes to see the flowers, I also look at the flowers, wrote for so many years of the page. I've been working with HTML 4.01 and XHTML for the first half of the day, but I don't remember much of it. I heard that some companies in the past will specifically let the dictation this, amen.

DWthe document type setting in

A lot of people get started from DW. With DW, you can find the edit-preferences-Create document-default document type setting in the menu. The corresponding picture is as follows:

Select the appropriate document type, and the header for the corresponding document type is automatically generated the next time you create it.

If you want to install B, remember that these characters are not the first. I would say that you have a pain in the egg, you can remember this (ok I also have a pain), XHTML similar.
The 1th step is to remember the basic code

<! DOCTYPE htmlpublic "-//w3c//dtd HTML 4.01 fill in the blanks 1//en" "http://www.w3.org/TR/html4/fill in the blanks 2.dtd" >

2nd Step Remember Document type English

HTML 4.01 Type Strict (empty Strict) transitional (Transitionnal Loose) Frameset (Frameset Frameset)

3rd step, fill in.

If you are silently remembering, one you can go bragging, the other you should try HTML5 as soon as possible.

Little Tips
    • Declaration does not have an end tag
    • The declaration is not case sensitive
    • Always add <! to an HTML document Doctype> declaration so that the browser can learn the document type.
    • The declaration must be the first line of the HTML document
    • The declaration is not an HTML tag; it is a directive that instructs the Web browser to write which HTML version of the page to use.
Summary

Personal humble opinion: Throughout the evolution of HTML, document type Browser parsing page according to the standard, promote the development of HTML language, but also convenient for the vast number of page developers, can focus on innovation page content, rather than all kinds of compatibility. The appearance of HTML5 is also the development after this unification. We do not seek their own independence, but to create a better ecological environment, the implementation of standards as the goal. After that, the contents of the history are left to us to brag about. It's wrong to say it, and I really hope that I can point it out to correct my long-standing cognitive mistakes.

Appendix I: SGML

The following content from Baidu Encyclopedia

Introduction

The tags are divided into two types:
A style, called procedardmarkup, used to describe the display of a document;
Another is called descriptive markup, which is used to describe the purpose of the text in a document. The basic idea of developing SGML is to separate the contents of the document from the style.

Working principle

A typical document can be divided into 3 levels: structure (structure), content, and style. SGML mainly deals with the relationship between structure and content.

(1) structure

To describe the structure of a document, SGML defines a file, called a document type definition (DocumentType definition,dtd), that provides a framework for document elements that organize documents, such as chapter and chapter headings, sections, and topics. In addition, DTDs establish rules for the interrelationships between document elements. For example, the title of a chapter must be the first document element after the beginning of the chapter, and at least two items per list. These rules that are defined by DTDs ensure document consistency.

(2) content

What this refers to is the information itself. The content includes the information name (title), paragraph, item list, and the specific content in the table, specific graphics and sounds, and so on. The method for determining the location of content in the DTD structure is called "tagging (tagging)", whereas creating SGML documents is essentially inserting the appropriate labels around the content. These are tags that mark the beginning and end of each part of the structure.

Talk about HTML <! Doctype> Label

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.