Before we formally introduce document types (DTDs) and DOCTYPE, we need to understand the differences between HTML and XHTML, and now HTML5 is slowly becoming mainstream, The previous decades have been the Html4.01 of the world, and Html4.01 has become a standard in the HTML version of most people since 1999. In 2000, the HTML4.01 published the XML version named XHTML1.0. The main difference between Html4.01 and XHTML1.0 is that the XML coding conventions are adhered to, and the tag closure is the XML Basic specification. XHTML1.1 is closer to XML as a later person, but compared to XHTML1.0, XHTML1.0 can be used as an HTML document, XHTML1.1 pages are sent as XML to the browser, even if XHTML1.1 contains only one error (unsigned & symbols). The Web browser cannot display the page because XHTML1.1 is not popular.
HTML5 and XHTML2
HTML is an application based on standard Generalized Markup Language (SGML), and XHTML is based on Extensible Markup Language (XML), and HTML and XHTML are two standards for parallel development. In essence, XHTML is a transition technology that combines the power of some XML with the simple nature of most HTML. The goal of XHTML is to make the HTML transition to XML. XML is designed to transmit and carry data, not to represent or display data, and HTML to represent data.
XHTML only improves the original HTML system on the content structure, and XHTML2.0 only pays more attention to page specification and usability and lacks interactivity on the basis of XHTML1.1. In the era of Web apps, XHTML2 was out of the way, and it gave birth to HTML5. In defiance of web designers ' needs, the company has been carrying a standard banner from a theoretical standpoint, triggering objections from browser makers such as opera, Apple and Mozilla. In 2004, they formed a working group on Web Hypertext Technology (Web Hypertext Application Technology Working Group, abbreviated as WHATWG), which was designed to drive the network HTML5 standards. The HTML5 goal is to replace the HTML4.01 and XHTML1.0 standards, designed to improve web page performance and increase page interaction. HTML5 draws on some XHTML2 suggestions, including some features to improve the structure of the document, such as the use of new HTML tag Headers, footer, dialog, aside, figure, and so on, which will enable content creators to create documents more semantically, The previous developers used Div for all these occasions. after years of efforts, the WHATWG and the two sides finally reached a compromise in 2006. In October 2006, the father of the Web, the chairman of the World Wide Web Consortium (Tim Berners), and a member of the National Academy of Sciences, Tim Berners-lee, published a blog post saying that the path from HTML to XML would not work (XHTML is dead). In 2009, it wisely abandoned its plan to improve the XHTML2.0 standard and chose WHATWG's results as the basis. In fact, XHTML has not been modified for several years after the 2002 update, despite the many problems it has discovered. On October 29, 2014, the HTML5 standard specification was finally finalized. Document Types (DTDs) and DOCTYPE
A document type definition is a set of syntax rules about a marker that defines what is allowed in a particular version of XML or HTML, what is not allowed, When rendering parsing pages, the browser checks the validity of the page against these rules and takes appropriate action. About DOCTYPE's three styles, strict (strict), transition (transitional) and frame set (frameset). <! The doctype> declaration must be the first line in the HTML document, before the
Html4.01 and XHTML1.0:
Strict mode:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD" >
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
Transition (Transitional) mode:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
Framework set (FRAMESET):
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 frameset//en" "HTTP://WWW.W3.ORG/TR/HTML4/FRAMESET.DTD" >
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 frameset//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd" >
The framework set (frameset) uses less, the strict style DTD contains all the HTML elements and attributes, but does not include both the display and deprecated elements (such as font), and the transitional (transitional) style DTD still uses the deprecated elements. But HTML5 not need to be so complicated, there is only one doctype:
<! DOCTYPE html>
When browser vendors create a standard-compatible browser, they want to determine backwards compatibility, in order to achieve this they create two rendering modes, standard mode and promiscuous mode (quirks mode), in standard mode, the browser renders the page according to the specification, in promiscuous mode, The page is displayed in a more relaxed backward-compatible manner. Html4.01 if the DOCTYPE containing the DTD are rendered in standard mode, the HTML and XHTML documents are rendered in promiscuous mode if the DOCTYPE does not exist or is improperly formed.
html-Document Types (DTDs) and DOCTYPE