Jump to content

Document type declaration: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
→‎XHTML 1.0 DTDs: missed a "/"
Farazy (talk | contribs)
No edit summary
Line 45: Line 45:


<nowiki><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"></nowiki>
<nowiki><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"></nowiki>

===XHTML 1.1 DTDs===

This is the latest DTD that has the stringency of XHTML 1.0 Strict, and it is based upon the module framework and modules defined in Modularization of XHTML.

<nowiki><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"></nowiki>


==See also==
==See also==

Revision as of 03:24, 30 September 2006

A Document Type Declaration, or DOCTYPE, associates a particular SGML or XML document with a Document Type Definition (DTD). In the serialized form of the document, it manifests as a short string of markup that conforms to a particular syntax.

Despite its name, a Document Type Declaration is not suitable for deducing the type of the document, although apparently it was originally supposed to be.

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

DTDs

A Document Type Declaration can be found in the source code of every Wikipedia page.

Example

The first line of many Wikipedia pages reads as follows:

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

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. The root element is declared to be html.

HTML 4.01 DTDs

HTML 4.01 Strict does not allow presentational markup with the argument that you should use Cascading Style Sheets for that instead. This is how the strict doctype looks:

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

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

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

Also if you are using frames, to get valid results from the SGML validator, you need the frameset doctype, like this:

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

XHTML 1.0 DTDs

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

XHTML Strict DTD is the strictest DTD available: no deprecated tags are supported and the code must be written correctly.

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

XHTML Transitional DTD is like the XHTML Strict DTD, but deprecated tags are allowed. This is the most popular current DTD.

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

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

XHTML 1.1 DTDs

This is the latest DTD that has the stringency of XHTML 1.0 Strict, and it is based upon the module framework and modules defined in Modularization of XHTML.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

See also