Complete version of DOCTYPE elements

Time:2021-6-22

1、 Overview

This paper systematically explains the element of DOCTYPE. At the same time, it checks a lot of information. Because the information on the Internet is messy, I redefine it after collection. For example, the definition of DOCTYPE element is mainly divided into basic knowledge and advanced knowledge. Basic knowledge explains basic DOCTYPE knowledge. Many advanced knowledge comes from network collection, Mainly some practical skills

2、 Definition

DOCTYPE is the abbreviation of document type! The DOCTYPE > element is used to declare the document type declaration (DTD) of a page. This element declaration is located at the front of the document, before the < HTML > tag. By confirming the DTD of the page, you can also determine which W3C specification (such as HTML or XHTML) the page uses.

3、 W3C specification

The correct translation of W3C specification should be W3C recommendations. In the eyes of many designers, W3C is the standard, but many people know little about it

W3C HTML specification and timeline

standard

recommend

HTML 3.2

January 14, 1997

HTML 4.0

May 24, 1998

HTML 4.01

December 24, 1999

W3C XHTML specification and timeline

standard

Draft / proposal

recommend

XHTML 1.0

  

26 January 2000

XHTML 1.0 revision

  

1 August 2002

XHTML 1.1

  

31 May 2001

XHTML Modules

  

10 April 2001

XHTML Modules 1.1

5 July 2006

  

XHTML Basic

  

19 December 2000

XHTML Basic 1.1

5 July 2006

  

XHTML Events

  

14 October 2003

XHTML Events 2

16 February 2007

  

XHTML Print

  

20 September 2006

XHTML Media Types

1 August 2002

  

XForms 1.0

  

14 October 2003

XForms 1.0 (SE)

  

14 March 2006

XForms 1.1

22 February 2007

  

XHTML 2.0

26 July 2006

  

XLink

  

27 June 2001

HLink

13 September 2002

  

     

XHTML can be regarded as the latest HTML specification, which is an XML application that can migrate smoothly from HTML 4.01. W3C’s first step in refactoring HTML 4.01 into XML led to the birth of XHTML 1.0. XHTML 1.0 relies on the semantics provided by the HTML 4.01 tag.  

4、 Specification and DTD

Page files declare different DTDs through < DOCTYPE > elements to tell the browser which HTML or XHTML specifications the current page conforms to

HTML

HTML 4.01 specifies three document types: strict, transitional and frameset.


HTML Strict DTD

Use this type if you need clean markup to avoid the confusion of the presentation layer. Use with cascading style sheets (CSS)

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” ”
http://www.w3.org/TR/html4/strict.dtd“>


HTML Transitional DTD

A transitional DTD can contain rendering attributes and elements that W3C expects to move into the stylesheet. If your readers use browsers that don’t support cascading style sheets (CSS) so that you have to use the rendering features of HTML, use this type:

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” ”
http://www.w3.org/TR/html4/loose.dtd“>


Frameset DTD

Frameset DTDs should be used for documents with frames. Except that frameset element replaces body element, frameset DTD is equivalent to transitional DTD

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Frameset//EN” ”
http://www.w3.org/TR/html4/frameset.dtd“>

  

XHTML

XHTML 1.0 specifies three XML document types: strict, transitional, and frameset.


XHTML Strict DTD

Use this type if you need clean markup to avoid the confusion of the presentation layer. Use with cascading style sheets (CSS)

<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd“>


XHTML Transitional DTD

A transitional DTD can contain rendering attributes and elements that W3C expects to move into the stylesheet. If your readers use browsers that don’t support cascading style sheets (CSS) so that you have to use the rendering features of XHTML, use this type:

<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>


XHTML Frameset DTD

Use this DTD when you want to use the framework!

<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN”
http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd“>

  

5、 DOCTYPE element syntax

grammar

HTML top level element availability “register / / organization / / type label / / definition language” “URL”

  

Syntax element description

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

  

Availability: Specifies whether the formal public identifier (FPI) is a publicly accessible object or a system resource. The value can be public or system.public by default. Represents an object that is publicly accessible. System represents system resources, such as local files or URLs.

  

Registration: Specifies whether the organization is registered by the international organization for Standardization (ISO).

+Is the default, indicating that the organization name is registered.

-Indicates that the organization name is not registered. IETF and W3C are not registered ISO organizations.

  

Organization: designation indicates responsibility by! DOCTYPE declares the name of the group or organization that creates and maintains the referenced DTD, that is, the ownerid. IETF is IETF. W3C is W3C.

  

Type: Specifies the public text class, that is, the type of object referenced. The default is DTD.

  

Label: Specifies the description of the public text, that is, the unique descriptive name of the quoted public text. The version number can be attached. The default is HTML.

  

Definition: Specifies the document type definition.

Frameset document.

Strict excludes all representative attributes and elements that W3C experts want to phase out because the stylesheet is perfect.

Transitional contains everything 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 as ISO 639 language code (two letters in capitals). EN default. English.

  

URL: Specifies the location of the referenced object.  

  

6、 Inspection tools

If you want to check whether your page content meets the standards declared in DOCTYPE, you can use the verification tool provided by W3C

http://validator.w3.org/

  

7、 DOCTYPE switch

Modern browsers include different rendering modes to support both W3C compliant web pages and web pages designed for older browsers. Among them, standards mode (i.e. strict rendering mode) is used to render web pages that follow the latest standards, while quirks mode (i.e. loose rendering mode or compatible mode) is used to render web pages designed for traditional browsers. In addition, notice that Mozilla / Netscape 6 adds an almost standards mode to support web pages designed for an older version of the standard.

   

In theory, this should be a very intuitive switch. If the <! The DOCTYPE > element indicates that the page follows standards (such as XHTML 1.0), and the browser switches to standards mode. If no DOCTYPE is specified, or HTML 3.2 or older is specified, the browser switches to quirks mode. In this way, the browser can display the standard documents correctly without abandoning the old-fashioned web pages.However, there are the following situations:

1. Missing URL or relative URL

In the complete DOCTYPE declaration, include the URL of the corresponding document type definition (DTD) file. If the URL is missing, or if a relative path (rather than a fully qualified Internet address) is specified, most browsers will enter quirks mode, regardless of the mode specified in the DOCTYPE declaration.

  

2. Wrong DOCTYPE

The browser is very sensitive to the form and format of the DOCTYPE declaration. If a DOCTYPE with wrong form cannot be recognized, it will be forced into quirks mode (it is recommended to copy and paste a known correct DOCTYPE into the document instead of entering it in person). A common reason for the wrong form of DOCTYPE is the lack of a space between the first part of the DOCTYPE and the URL. If you collapse a two line DOCTYPE into a single line, you often lose that space.

  

3. DOCTYPE of transition period

When the browser handles the DOCTYPE in the transitional period, it is most likely to cause inconsistency. IE and opera use standards mode; Netscape 6 and old version of safari use quirks mode; Netscape 7, Mozilla 1 and the new version of safari use Netscape’s almost standards mode, which is a more fault-tolerant version of standards mode.

  

4. Unknown DOCTYPE

There are also inconsistencies when browsers handle unrecognized DOCTYPES. IE and opera will enter the standards mode; In other words, it assumes that the unrecognized DOCTYPE is a new standard that has not yet been integrated in the browser. Netscape 6, on the contrary, switches to quirks mode when encountering an unrecognized DOCTYPE.

   

DOCTYPE switching may be an effective way to let the browser enter the correct rendering mode and display the web page correctly, provided that you notice the inconsistency of various browsers and can actively avoid various problems.     

8、 How to use XHTML

1. The above DOCTYPE declaration is followed by an XHTML namespace declaration in the enhanced < HTML > element

<html xmlns=”http://www.w3.org/1999/xhtml“>

   

2. Because XHTML 1.0 page is a legal XML document, and XML is case sensitive for tags and attributes, for the sake of simplicity, all tags and attributes in XHTML 1.0 page must be lowercase.

Some free tools, such as HTML tidy(http://tidy.sourceforge.net/), which can help you automatically convert labels and attributes to lowercase.

   

3. Declare the language used in the page by adding a < meta > element to the < head > element.

<meta http-equiv=”Content-Type” content=”text/html; charset=gbk” />

   

4. In XHTML, all attributes must be quoted.

Some free tools, such as HTML tidy(http://tidy.sourceforge.net/)To help you automatically quote all attributes.

   

5. In XHTML, all attributes must have values.

You can’t write as you did in HTML 4.0:

<input type=”checkbox” name=”shirt” value=”medium” checked>

It should be written as follows:

<input type=”checkbox” name=”shirt” value=”medium” checked=”checked” />

   

6. In XHTML, all tags must be closed.

There are two ways to close the tag. The tag containing content is closed with the end tag, and the empty tag is followed by a space and a ‘/’. For example:

<p>This is acceptable HTML and it is also valid XHTML.</p>

<img src=”logo.gif” />

7. Do not use “–” in comments.

“–” can only be used at the beginning and end of XHTML comments, not in the content of comments. The following are not allowed:

<!–Invalid — and so is the classic “separator” below. –>

<!————————————>

8. HTML code all special symbols.  

W3C’s XHTML / CSS / DOM constitute a complete and rigorous system. I call these three specifications “the incarnation of Trinity god” in the web world. These three specifications represent the structure, presentation and behavior of web pages respectively. It is helpful to improve the reusability and modularity of web pages and reduce the cost of making, maintaining and modifying web pages. In order to achieve the above layered goal, the XHTML should only contain structure related tags (elements and attributes). Therefore, we should get used to using the DTD of the type of strict, and abandon those tags with expressive meaning as soon as possible (these tags are marked as “not recommended” in the HTML 4.0 specification, and will be completely abandoned in the later versions of XHTML); As soon as possible abandon the old method of layout based on table and adopt complete CSS layout. 

 

9、 Recommended XHTML related books

An authoritative guide to HTML and XHTML, written by chuck musciano & bill Kennedy.

The XHTML tutorial, written by Chelsea Valentine & Chris Minnick.

Website refactoring, by Jeffrey Zeldman.
Author: Zhang Ziqiu
source: http://www.cnblogs.com/zhangziqiu/

Recommended Today

Tutorial on sending e-mail using net:: SMTP class in Ruby

Simple Mail Transfer Protocol(SMTP)SendE-mailAnd routing protocol processing between e-mail servers. RubyIt provides the connection of simple mail transfer protocol (SMTP) client of net:: SMTP class, and provides two new methods: new and start New takes two parameters: Server name defaults to localhost Port number defaults to 25 The start method takes these parameters: Server – […]