A Document Type Definition (DTD) is used to define the syntax of HTML and XHTML documents. It contains the rules of the HTML and XHTML language.
HTML5 does not use a DTD. HTML5 is declared by using the following: <!DOCTYPE html>
The first thing that a HTML or XHTML document should include is the document type declaration.
List of DOCTYPE declarations from the W3C website. List of DOCTYPE declarations
DOCTYPE Syntax information from the W3C website. DOCTYPE Syntax
HTML5 document type declaration.
HTML5
<!DOCTYPE html>
HTML 4.01 and XHTML 1.0 document type declarations.
HTML 4.01 - Strict
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
HTML 4.01 - Transitional
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
HTML 4.01 - Frameset
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
XHTML 1.0 - Strict
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
XHTML 1.0 - Transitional
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
XHTML 1.0 - Frameset
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
HTML5 sample document that can be used as a template.
HTML5 Template - Note: The lang attribute, in the <html> tag, is set to "en" which is the language code for English. If this is not the intended document language then this value should be changed to the appropriate language code. Use of the lang attribute is encouraged because it can be useful for braille translation software, speech synthesizers, dictionary definitions, etc.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Your Title</title> </head> <body> Your HTML here </body> </html>
HTML 4.01 and XHTML 1.0 sample documents that can be used as templates.
HTML 4.01 Transitional Template - Note: The lang attribute, in the <html> tag, is set to "en" which is the language code for English. If this is not the intended document language then this value should be changed to the appropriate language code. The lang attribute is not required but it is useful for braille translation software, speech synthesizers, dictionary definitions, etc.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <title>Your Title</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> </head> <body> Your HTML here </body> </html>
XHTML 1.0 Transitional Template - Note: The lang and xml:lang attributes, in the <html> tag, are set to "en" which is the language code for English. If this is not the intended document language then these values should be changed to the appropriate language code. The lang and xml:lang attributes are not required but they are useful for braille translation software, speech synthesizers, dictionary definitions, etc.
<!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" lang="en" xml:lang="en"> <head> <title>Your Title</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> </head> <body> Your HTML here </body> </html>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />OR
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />When using XHTML version 1.0, the Internet Media Type can be set to "text/html" if the "HTML Compatibility Guidelines" are followed. See XHTML 1.0 The Extensible HyperText Markup Language (Second Edition) for more details. Reference section "5.1. Internet Media Type" and "Appendix C." The XHTML 1.0 Transitional Template, shown above, sets content equal to "text/html."