XHTML/DTD (Document Type Definition)

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Introduction[edit | edit source]

An XHTML DTD describes the allowed syntax and grammar of XHTML markup. Every XHTML document must start with a DTD declaration and a line of code that declares that you are starting to write XHTML code.

This is the mandatory minimum way to start an XHTML document:

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

<html xmlns="http://www.w3.org/1999/xhtml">

The Three Document Type Definitions[edit | edit source]

There are currently three XHTML 1.0 document types:

  • Strict
  • Transitional
  • Frameset

XHTML 1.0 Strict[edit | edit source]

This is used when the user wants a clean markup, free of presentational clutter. Use this in conjunction with Cascading Style Sheets.

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

XHTML 1.0 Transitional[edit | edit source]

Use this when taking advantage of XHTML's presentational features and when you want to support browsers that do not understand Cascading Style Sheets. This is the one that is favoured to use amongst developers and is used commonly.

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

XHTML 1.0 Frameset[edit | edit source]

Use this when you want to use XHTML Frames to partition the browser window into two or more frames.

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

XHTML 1.1[edit | edit source]

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

XHTML 2.0[edit | edit source]

XHTML was a working draft, but its development was halted in favour of HTML 5.0. Even though the specification will not be completed, its doctype is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 2.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml2.dtd">