词条 | Document type declaration |
释义 |
A document type declaration, or DOCTYPE, is an instruction that associates a particular SGML (for example, a webpage) with a document type definition (DTD) (for example, the formal definition of a particular version of HTML 2.0 - 4.0) or XML document.[1] In the serialized form of the document, it manifests as a short string of markup that conforms to a particular syntax. The HTML layout engines in modern web browsers perform DOCTYPE "sniffing" or "switching", wherein the DOCTYPE in a document served as DTDsSyntaxThe general syntax for a document type declaration is: ]> or ]> In XML, the root element that represents the document is the first element in the document. For example, in XHTML, the root element is <html>, being the first element opened (after the doctype declaration) and last closed. The keywords SYSTEM and PUBLIC suggest what kind of Document Type Definition (DTD) it is (one that is on a private system or one that is open to the public). If the PUBLIC keyword is chosen then this keyword is followed by a restricted form of "public identifier" called Formal Public Identifier (FPI) enclosed in double quote marks. After that, necessarily, a "system identifier" enclosed in double quote marks, too, is provided. For example, the FPI for XHTML 1.1 is "-//W3C//DTD XHTML 1.1//EN" and, there are 3 possible system identifiers available for XHTML 1.1 depending on the needs, one of them is the URI reference "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd". If, instead, the SYSTEM keyword is chosen, only a system identifier must be given. It means that the XML parser must locate the DTD in a system specific fashion, in this case, by means of a URI reference of the DTD enclosed in double quote marks. The last part, surrounded by literal square brackets ([]), is called an internal subset which can be used to add/edit entities or add/edit PUBLIC keyword behaviors.[3] The internal subset is always optional (and sometimes even forbidden within simple SGML profiles, notably those for basic HTML parsers that don't implement a full SGML parser). On the other hand, document type declarations are slightly different in SGML-based documents such as HTML, where the public identifier may be associated with the system identifier. This association might be performed, e. g., by means of a catalog file resolving the FPI to a system identifier.[4] ExampleThe first line of many World Wide Web pages reads as follows: This document type declaration for XHTML includes by reference a DTD, whose public identifier is Common DTDsSome common DTDs have been put into lists. W3C has produced a list of DTDs commonly used in the web, which contains the "bare" HTML5 DTD, older XHTML/HTML DTDs, DTDs of common embedded XML-based formats like MathML and SVG as well as "compound" documents that combine those formats.[5] Both W3C HTML5 and its corresponding WHATWG version recommend browsers to only accept XHTML DTDs of certain FPIs and to prefer using internal logic over fetching external DTD files. It further specifies an "internal DTD" for XHTML which is merely a list of HTML entity names.[6]{{rp|at=§13.2}} HTML 4.01 DTDsStrict DTD does not allow presentational markup with the argument that Cascading Style Sheets should be used for that instead. This is how the Strict DTD looks: Transitional DTD allows some older PUBLIC and attributes that have been deprecated: If frames are used, the Frameset DTD must be used instead, like this: XHTML 1.0 DTDsXHTML's DTDs are also Strict, Transitional and Frameset. XHTML Strict DTD. No deprecated tags are supported and the code must be written correctly according to XML Specification. XHTML Transitional DTD is like the XHTML Strict DTD, but deprecated tags are allowed. XHTML Frameset DTD is the only XHTML DTD that supports Frameset. The DTD is below. XHTML 1.1 DTDXHTML 1.1 is the most current finalized revision of XHTML, introducing support for XHTML Modularization. XHTML 1.1 has the stringency of XHTML 1.0 Strict. XHTML Basic DTDsXHTML Basic 1.0 XHTML Basic 1.1 HTML5 DTD-less DOCTYPEHTML5 uses a In other words, {{code|lang=html|}}, case-insensitively. With the exception of the lack of a URI or the FPI string (the FPI string is treated case sensitively by validators), this format (a case-insensitive match of the string In XHTML5 the The See also
References1. ^[https://www.w3.org/MarkUp/html-spec/html-pubtext.html HTML2] [https://www.w3.org/TR/2018/SPSD-html32-20180315/#dtd HTML3] [https://www.w3.org/TR/1998/REC-html40-19980424/sgml/dtd.html HTML4] 2. ^{{cite web |url=http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#the-doctype |title=The HTML syntax ― HTML5 |accessdate=2011-06-05}} 3. ^{{cite web|url=http://msdn.microsoft.com/en-us/library/ms256059.aspx|title=DOCTYPE Declaration|author=|date=|website=msdn.microsoft.com}} 4. ^{{Cite web |url=http://www.freebsd.org/doc/en/books/fdp-primer/sgml-primer-doctype-declaration.html# |title=Archived copy |access-date=2011-09-09 |archive-url=https://web.archive.org/web/20110814080220/http://www.freebsd.org/doc/en/books/fdp-primer/sgml-primer-doctype-declaration.html# |archive-date=2011-08-14 |dead-url=yes |df= }} 5. ^{{cite web |title=W3C QA - Recommended list of Doctype declarations you can use in your Web document |url=https://www.w3.org/QA/2002/04/valid-dtd-list.html |website=www.w3.org |accessdate=22 March 2019 |language=en}} 6. ^{{cite web |title=HTML Standard |url=https://html.spec.whatwg.org/multipage/xhtml.html#parsing-xhtml-documents |website=html.spec.whatwg.org |accessdate=22 March 2019}} 7. ^{{cite web |url=http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#the-doctype |title=The HTML syntax ― HTML5 |publisher=Web Hypertext Application Technology Working Group | accessdate=2011-06-05 |quote=3. A string that is an ASCII case-insensitive match for the string "DOCTYPE". ... 5. A string that is an ASCII case-insensitive match for the string "HTML".}} 8. ^{{cite web | url=http://www.whatwg.org/specs/web-apps/current-work/multipage/the-xhtml-syntax.html#writing-xhtml-documents | title=The XHTML syntax ― HTML5 | publisher=Web Hypertext Application Technology Working Group | accessdate=2009-09-01 | deadurl=yes | archiveurl=https://www.webcitation.org/68FQUUsTr?url=http://www.whatwg.org/specs/web-apps/current-work/multipage/the-xhtml-syntax.html | archivedate=2012-06-07 | df= }} 9. ^{{cite web|url=http://www.w3.org/TR/html-polyglot/#doctype | title=Polyglot Markup: HTML-Compatible XHTML Documents | publisher=World Wide Web Consortium | accessdate=2012-01-17}} External links{{Wiktionary|doctype}}{{Wikibooks|Authoring Webpages/HTML, XHTML and DOCTYPEs}}
1 : XML-based standards |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。