XHTML DOCTYPE

tutorial and example
tutorial and example

DOCTYPE is an instruction that associates to a particular SGML or XML (like a webpage) document with a DTD(Document Type Definition).

DOCTYPE is the first statement of the XHTML document.

DTD helps in describing the rules for the markup languages, so that the browsers render the content correctly.

Three types of Doctypes available in XHTML are:

  • Strict
  • Transitional
  • Frameset

Transitional Doctype is the mostly commonly used Doctype in XHTML.

We need to select XHTML elements and attributes carefully while writing XHTML document because few XHTML elements and attributes which are available in one DTD but not available in another DTD.

XHTML 1.0 Strict

Use XHTML 1.0 Strict, when we want to use CSS (Cascading Style Sheet) and don’t want to write most of the XHTML attributes.

Use the following DTD at the top of your XHTML document.

Syntax

XHTML 1.0 Transitional

Use XHTML 1.0 Transitional, when we want to use many XHTML attributes and few CSS properties.

Use the following DTD at the top of your XHTML document.

Syntax

XHTML 1.0 Frameset

Use XHTML 1.0 Frameset, when we want to use HTML frames to partition the browser window into two or more frames.

Use the following DTD at the top of your XHTML document.

Syntax