Document Type Declaration

Document Type Declaration

A Document Type Declaration, or DOCTYPE, is an instruction that associates a particular SGML or XML document (for example, a webpage) with a Document Type Definition (DTD) (for example, the formal definition of a particular version of HTML). 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 text/html determines a layout mode, such as "quirks mode" or "standards mode". The text/html serialization of HTML5, which is not SGML-based, uses the DOCTYPE only for mode selection. Since web browsers are implemented with special-purpose HTML parsers, rather than general-purpose DTD-based parsers, they don't use DTDs and will never access them even if a URL is provided. The DOCTYPE is retained in HTML5 as a "mostly useless, but required" header only to trigger "standards mode" in common browsers.[1]

Contents

DTDs

Syntax

The general syntax for a document type declaration is:

<!DOCTYPE root-element PUBLIC "FPI" ["URI"] [ 
<!-- internal subset declarations -->
]>

or

<!DOCTYPE root-element SYSTEM "URI" [ 
<!-- internal subset declarations -->
]>

In XML, the root element of 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 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 behaviours.[2] 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 you may associate the public identifier with the system identifier. This association might be performed, e. g., by means of a catalog file resolving the FPI to a system identifier.[3]

Example

The first line of many World Wide Web pages reads as follows:

<!DOCTYPE html PUBLIC
  "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="ar" dir="rtl" xmlns="http://www.w3.org/1999/xhtml">

This Document Type Declaration for XHTML includes by reference a DTD, whose public identifier is -//W3C//DTD XHTML 1.0 Transitional//EN and whose system identifier is http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd. An entity resolver may use either identifier for locating the referenced external entity. No internal subset has been indicated in this example or the next ones. The root element is declared to be html and, therefore, it is the first tag to be opened after the end of the doctype declaration in this example and the next ones, too. The html tag is not part of the doctype declaration but has been included in the examples for orientation purposes.

HTML 4.01 DTDs

Strict 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:

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

Transitional DTD allows some older PUBLIC and attributes that have been deprecated:

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

If frames are used, the Frameset DTD must be used instead, like this:

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

XHTML 1.0 DTDs

XHTML's DTDs are also Strict, Transitional and Frameset.

XHTML Strict DTD. No deprecated tags are supported and the code must be written correctly.

 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 


XHTML Transitional DTD is like the XHTML Strict DTD, but deprecated tags are allowed.

 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 


XHTML Frameset DTD is the only XHTML DTD that supports Frameset. The DTD is below.

 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 

XHTML 1.1 DTD

XHTML 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.

<!DOCTYPE html PUBLIC
  "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html lang="ar" dir="rtl" xmlns="http://www.w3.org/1999/xhtml">

XHTML Basic DTDs

XHTML Basic 1.0

<!DOCTYPE html PUBLIC
  "-//W3C//DTD XHTML Basic 1.0//EN"
  "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html lang="ar" dir="rtl" xmlns="http://www.w3.org/1999/xhtml">

XHTML Basic 1.1

<!DOCTYPE html PUBLIC
  "-//W3C//DTD XHTML Basic 1.1//EN"
  "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
<html lang="ar" dir="rtl" xmlns="http://www.w3.org/1999/xhtml">

XHTML Mobile Profile DTDs

XHTML Mobile Profile 1.0

<!DOCTYPE html PUBLIC
  "-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
  "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html lang="ar" dir="rtl" xmlns="http://www.w3.org/1999/xhtml">

XHTML Mobile Profile 1.1

<!DOCTYPE html PUBLIC
  "-//WAPFORUM//DTD XHTML Mobile 1.1//EN"
  "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd">
<html lang="ar" dir="rtl" xmlns="http://www.w3.org/1999/xhtml">

XHTML Mobile Profile 1.2

<!DOCTYPE html PUBLIC
  "-//WAPFORUM//DTD XHTML Mobile 1.2//EN"
  "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">
<html lang="ar" dir="rtl" xmlns="http://www.w3.org/1999/xhtml">

XHTML + RDFa DTD

XHTML+RDFa 1.0

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
    "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html lang="ar" dir="rtl" xmlns="http://www.w3.org/1999/xhtml">

HTML5 DTD-less DOCTYPE

HTML5 uses a DOCTYPE declaration which is very short, due to its lack of references to a Document Type Definition in the form of a URL and/or FPI. All it contains is the tag name of the root element of the document, HTML.[4] In the words of the specification draft itself:

In other words, <!DOCTYPE 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 !DOCTYPE HTML) is the same as found in the syntax of the SGML based HTML 4.01 DOCTYPE. Both in HTML4 and in HTML5, the formal syntax is defined in upper case letter, even if both lower case and mixes of lower case upper case are also treated as valid.

In XHTML5 the DOCTYPE has to be a case-sensitive match of the string "<!DOCTYPE html>". This is because in XHTML syntax all HTML PUBLIC are required to be in lower case, including the root element referenced inside the HTML5 DOCTYPE. As well, XHTML only accepts the upper case inside the DOCTYPE string. These rules are not defined by the HTML5 specification itself but by XML and the syntax rules for XHTML DTDs. For the XHTML5 syntax, then Document Type Definitions are permitted as well.

The DOCTYPE is optional in XHTML5 and may simply be omitted,[5] though many layout engines render such documents in Quirks mode. This would be a problem whenever the document is supposed to be consumed by text/html parser as well as by XHTML (application/xhtml+xml) parsers. Given, however, that the HTML5 specification forbids XML-serialized HTML5 (XHTML5) from being served with any MIME type other than application/xhtml+xml, this is unlikely to be a situation encountered in the real-world. Unlike with the previous versions of XHTML, it is impossible to serve an XHTML5 (that is, HTML5 serialized as XML) document as text/html in any conceivable situation; any situation involving XHTML5 will be served as application/xhtml+xml and parsed as XML in a standards-compliant system.

See also

References

External links


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Document Type Definition — (DTD) is a set of markup declarations that define a document type for SGML family markup languages (SGML, XML, HTML). DTDs were a precursor to XML schema and have a similar function, although different capabilities. DTDs use a terse formal syntax …   Wikipedia

  • Document Type Definition — Pour les articles homonymes, voir Définition (Homonymie). La Document Type Definition (DTD), ou Définition de Type de Document, est un document permettant de décrire un modèle de document SGML ou XML. Le modèle est décrit comme une grammaire de… …   Wikipédia en Français

  • Document Schema Definition Languages — (DSDL) is a framework within which multiple validation tasks of different types can be applied to an XML document in order to achieve more complete validation results than just the application of a single technology. It is specified by the… …   Wikipedia

  • déclaration — [ deklarasjɔ̃ ] n. f. • XIIIe; lat. declaratio 1 ♦ Action de déclarer; discours ou écrit par lequel on déclare. Faire, prononcer, rédiger une déclaration. Selon sa propre déclaration : selon ce qu il a dit lui même. ⇒ aveu, 2. dire, parole.… …   Encyclopédie Universelle

  • Type approval — is granted to a product that meets a minimum set of regulatory, technical and safety requirements. Generally, type approval is required before a product is allowed to be sold in a particular country, so the requirements for a given product will… …   Wikipedia

  • Type de données — Type (informatique) Pour les articles homonymes, voir Type (homonymie). En programmation un type de données, ou simplement type, définit le genre de contenu d une donnée et les opérations pouvant être effectuées sur la variable correspondante.… …   Wikipédia en Français

  • Declaration de guerre — Déclaration de guerre États Unis : Le Président Franklin D. Roosevelt signe une déclaration de guerre contre l Allemagne le 11 décembre 1941. Une déclaration de guerre …   Wikipédia en Français

  • Déclaration De Guerre — États Unis : Le Président Franklin D. Roosevelt signe une déclaration de guerre contre l Allemagne le 11 décembre 1941. Une déclaration de guerre …   Wikipédia en Français

  • Declaration — Déclaration Cette page d’homonymie répertorie les différents sujets et articles partageant un même nom …   Wikipédia en Français

  • Declaration Schuman — Déclaration Schuman La Déclaration Schuman est l appel lancé le 9 mai 1950 par Robert Schuman, ministre français des Affaires étrangères, qui a mené à la création en 1951 de la Communauté européenne du charbon et de l acier (CECA), première des… …   Wikipédia en Français

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”