search
HomeWeb Front-endHTML TutorialDetailed explanation of DOCTYPE element full version_HTML/Xhtml_Web page production

1. Overview

This article systematically explains the DOCTYPE element. At the same time, I verified a lot of information. Because the information on the Internet is relatively messy, I redefined it after collecting and sorting it. For example, the definition of the DOCTYPE element is mainly divided into basic knowledge and advanced knowledge. .Basic knowledge explains basic DOCTYPE knowledge. A lot of advanced knowledge comes from the Internet, mainly some practical application skills.

2. Definition

DOCTYPE is the abbreviation of Document Type. The element is used to declare the Document Type Declaration (DTD) of a page. This element declaration is located at the forefront of the document. Before the tag. By confirming the DTD of the page, you can also determine which W3C specification the page uses (such as HTML or XHTML specification).

Three.W3C specifications

The correct translation of W3C specifications should be W3C Recommendations. In the eyes of many designers, W3C is the standard. But many people have only a partial understanding of it. The HTML specifications and XHTML specifications in the current W3C specifications are listed below. The relationship between HTML and XHTML will be explained later:

W3C HTML Specification and Timeline

规范

推荐

HTML 3.2

1997年1月14日

HTML 4.0

1998年5月24日

HTML 4.01

1999年12月24日

Specification

Recommended

HTML 3.2 January 14, 1997
HTML 4.0 May 24, 1998
HTML 4.01 December 24, 1999
W3C XHTML Specification and Timeline

Specifications

Draft/Proposal

Recommended

XHTML 1.0

January 26, 2000

XHTML 1.0 Revision

August 1, 2002

XHTML 1.1

May 31, 2001

XHTML Modules

April 10, 2001

XHTML Modules 1.1

July 5, 2006

XHTML Basic

December 19, 2000

XHTML Basic 1.1

July 5, 2006

XHTML Events

October 14, 2003

XHTML Events 2

February 16, 2007

XHTML Print

September 20, 2006

XHTML Media Types

August 1, 2002

XForms 1.0

October 14, 2003

XForms 1.0 (SE)

March 14, 2006

XForms 1.1

February 22, 2007

XHTML 2.0

July 26, 2006

XLink

June 27, 2001

HLink

September 13, 2002

​​

XHTML can be regarded as the latest HTML specification and is an XML application that can be smoothly migrated from HTML 4.01. The W3C's first step in refactoring HTML 4.01 to XML led to the birth of XHTML 1.0. XHTML 1.0 relies on the semantics provided by HTML 4.01 tags.

4. Specifications and DTD

The page file declares different DTDs through the element to tell the browser which HTML or XHTML specification the current page conforms to. Here are only the DTDs related to HTML4.01 and XHTML1.0 specifications:

HTML

HTML 4.01 specifies three document types: Strict, Transitional, and Frameset.


HTML Strict DTD

Use this type if you need clean markup without clutter in the presentation layer. Please use with Cascading Style Sheets (CSS):

ttp://www.w3.org/TR/html4/strict.dtd">http://www.w3.org/TR/html4/strict.dtd ">


HTML Transitional DTD

Transitional DTD can contain rendering attributes and elements that the W3C expects to be moved into style sheets. Use this type if your readers are using browsers that don't support Cascading Style Sheets (CSS) and you have to use HTML's rendering features:

ttp://www.w3.org/TR/html4/loose.dtd">http://www.w3.org/TR/html4/loose. dtd">


Frameset DTD

The Frameset DTD should be used for documents with frames. The Frameset DTD is equivalent to the Transitional DTD, except that the frameset element replaces the body element:

ttp://www.w3.org/TR/html4/frameset.dtd">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 without clutter in the presentation layer. Please use with Cascading Style Sheets (CSS):

br />PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1 /DTD/xhtml1-strict.dtd">


XHTML Transitional DTD

Transitional DTD can contain rendering attributes and elements that the W3C expects to be moved into style sheets. Use this type if your readers are using browsers that do not support Cascading Style Sheets (CSS) and you have to use the rendering features of XHTML:

br />PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1 /DTD/xhtml1-transitional.dtd">


XHTML Frameset DTD

When you wish to use a framework, use this DTD!

br />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 Element Availability "Registration//Organization//Type Tag//Definition Language" "URL"

Explanation of syntax elements

Top-level element: Specifies the type of top-level element declared in the DTD. This corresponds to the declared SGML document type. 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 a publicly accessible object. 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 has been registered.

- Indicates that 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 is IETF. W3C is W3C.

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

tag: Specify a public text description, that is, a unique descriptive name for the public text being referenced. A version number can be attached at the back. Default is HTML.

Definition: Specifies the document type definition.

Frameset Frameset documentation.

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.

6. Checking Tools

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

http://validator.w3.org/

Seven.DOCTYPE switching

Modern browsers include different rendering modes designed to support both web pages that adhere to W3C standards and web pages designed for older browsers. Among them, Standards mode (that is, strict rendering mode) is used to render web pages that comply with the latest standards, while Quirks (inclusive) mode (that is, loose rendering mode or compatibility mode) is used to render web pages designed for traditional browsers. . In addition, note that Mozilla/Netscape 6 adds a new 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 element of the page indicates that the page conforms to a standard (such as XHTML1.0), the browser will switch to Standards mode. If doctype is not specified, or HTML 3.2 and older is specified, the browser switches to Quirks mode. This way, the browser can correctly display standards-compliant documents without completely abandoning older, non-standard web pages. But there will be 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 a relative path is specified (rather than a fully qualified Internet address), most browsers will enter Quirks mode, regardless of the mode specified by the doctype declaration.

2. Wrong-formed doctype

Browsers are very sensitive to the form and format of doctype declarations. If a malformed doctype cannot be recognized, it will be forced into Quirks mode (it is recommended to copy and paste a known correct doctype into the document, and Not typing it in person). A common reason for a malformed doctype is a missing space between the first part of the doctype and the URL. Folding a two-line doctype into a single line often loses the space.

3. Transition doctype

When browsers handle transitional doctypes, inconsistencies are most likely to occur. IE and Opera use Standards mode; Netscape 6 and older versions of Safari use Quirks mode; Netscape 7, Mozilla 1, and newer versions 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 in how browsers handle unrecognized doctypes. IE and Opera will enter Standards mode; in other words, it assumes that the unrecognized doctype is a new standard that has not yet been integrated into the browser. Netscape 6, on the other hand, switches to Quirks mode when it encounters an unrecognized doctype.

Doctype switching may be an effective way to get the browser into the correct rendering mode and display the web page correctly, provided that you notice the inconsistencies in various browsers and can proactively avoid various problems.  

8. XHTML usage tips

1. Immediately following the above DOCTYPE declaration is an XHTML namespace declaration, placed in the enhanced element, written as:

http://www.w3.org/1999/xhtml">

2. Since XHTML 1.0 pages are legal XML documents, and XML is case-sensitive for tags and attributes, for the sake of simplicity, all tags and attributes in XHTML 1.0 pages must use lowercase.

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

3. Declare the language used in the page by adding a element to the element.

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
Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?Mar 04, 2025 pm 12:32 PM

The official account web page update cache, this thing is simple and simple, and it is complicated enough to drink a pot of it. You worked hard to update the official account article, but the user still opened the old version. Who can bear the taste? In this article, let’s take a look at the twists and turns behind this and how to solve this problem gracefully. After reading it, you can easily deal with various caching problems, allowing your users to always experience the freshest content. Let’s talk about the basics first. To put it bluntly, in order to improve access speed, the browser or server stores some static resources (such as pictures, CSS, JS) or page content. Next time you access it, you can directly retrieve it from the cache without having to download it again, and it is naturally fast. But this thing is also a double-edged sword. The new version is online,

How to efficiently add stroke effects to PNG images on web pages?How to efficiently add stroke effects to PNG images on web pages?Mar 04, 2025 pm 02:39 PM

This article demonstrates efficient PNG border addition to webpages using CSS. It argues that CSS offers superior performance compared to JavaScript or libraries, detailing how to adjust border width, style, and color for subtle or prominent effect

What is the purpose of the <datalist> element?What is the purpose of the <datalist> element?Mar 21, 2025 pm 12:33 PM

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

How do I use HTML5 form validation attributes to validate user input?How do I use HTML5 form validation attributes to validate user input?Mar 17, 2025 pm 12:27 PM

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

What are the best practices for cross-browser compatibility in HTML5?What are the best practices for cross-browser compatibility in HTML5?Mar 17, 2025 pm 12:20 PM

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

What is the purpose of the <progress> element?What is the purpose of the <progress> element?Mar 21, 2025 pm 12:34 PM

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

What is the purpose of the <meter> element?What is the purpose of the <meter> element?Mar 21, 2025 pm 12:35 PM

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

How do I use the HTML5 <time> element to represent dates and times semantically?How do I use the HTML5 <time> element to represent dates and times semantically?Mar 12, 2025 pm 04:05 PM

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.