


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
|
Recommended
|
||||||||
HTML 3.2 | January 14, 1997 | ||||||||
HTML 4.0 | May 24, 1998 | ||||||||
HTML 4.01 | December 24, 1999 |
Specifications |
Draft/Proposal |
Recommended |
January 26, 2000 |
||
August 1, 2002 |
||
May 31, 2001 |
||
April 10, 2001 |
||
July 5, 2006 |
||
December 19, 2000 |
||
July 5, 2006 |
||
October 14, 2003 |
||
February 16, 2007 |
||
September 20, 2006 |
||
August 1, 2002 |
||
October 14, 2003 |
||
March 14, 2006 |
||
February 22, 2007 |
||
July 26, 2006 |
||
June 27, 2001 |
||
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
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:
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.
鈥

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,

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

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

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

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

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

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

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


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor

Atom editor mac version download
The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

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.
