The XHTML WYSIWYG Editor For Desktop & Web Applications

DOCTYPE

Definition

Within the HTML/XHTML family of markup languages, differences between the markup languages are in some cases very subtle. For example, it may be only a question of the number of elements/attributes defined. W3C has written specifications that spell out the elements/attributes in each language. These specifications are called document type declarations or DTDs for short.

Since HTML/XHTML markup languages can be so similar, to help Web browsers (and other devices) identify the type of markup language used on a Web page, a document type declaration (DOCTYPE) that points to a specific DTD should be specified at the top of the Web page.

Example

In the first 2 lines of this example, the DOCTYPE XHTML 1.0 Strict is declared:

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <title>XHTML Reference</title>
  6. </head>
  7. <body>
  8. ...
  9. </body>
  10. </html>

This example declares the XHTML 1.1 DOCTYPE:

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  2. "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <title>XHTML Reference</title>
  6. </head>
  7. <body>
  8. ...
  9. </body>
  10. </html>

Best practice

A DOCTYPE is a commitment to follow the rules of a given markup language. Essentially, you are saying to a machine: "Anything that I send you will conform to the markup rules of the named DTD. So process what I send you according to those rules". For this reason, if markup that you supply does not conform to the specified rules, Web browsers or other devices may not process your markup as expected.

Note: the XHTML 1.1 DOCTYPE should only be used when Web pages are served as XML.