<!DOCTYPE>

<!DOCTYPE> — joriy dokumentning turini ko'rsatish uchun mo'ljallangan — DTD (document type definition, Hujjat turi ta'rifi).

Brauzer dokumentni turiga qarab uni interpretatsiya qiladi, chunki HTMLning bir necha versiyalari bor, bundan tashqari HTMLga o'xshash, sintaksis jihatidan biroz farq qiladigan XHTML ham bor. Shuning uchun .html faylning boshida uning turi <!DOCTYPE> yordamida ko'rsatiladi.

Quyidagi jadvalda <!DOCTYPE>ning turlarini ko'rishingiz mumkin.

DOCTYPE Ta'rifi
HTML 4.01
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> HTMLning qat'iy sintaksisi. (Eskirgan, ma'qullanmagan elementlardan xoli).
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> HTMLning o'tuvchi sintaksisi. (Eskirgan teglarni ham o'z ichiga oladi. HTMLning eski versiyalaridan o'tishda qo'llaniladi).
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> Freymlar qo'llanilgan HTML dokument uchun. (Xuddi o'tuvchi sintaksis kabi, shu bilan birga freymlar ham qo'llanilishi mumkin).
HTML 5
<!DOCTYPE html> Barcha dokumentlar uchun.
XHTML 1.0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> XHTMLning qat'iy sintaksisi.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> XHTMLning o'tuvchi sintaksisi.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> Freymlar qo'llanilgan XHTML dokument uchun.
XHTML 1.1
<!DOCTYPE html PUBLIC «-//W3C//DTD XHTML 1.1//EN» «http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd»> Barcha dokumentlar uchun.

Sintaksis

<!DOCTYPE [Yuqori darajadagi element] [Oshkoraligi] "[Ro'yxatdan o'tganligi]//[Tashkilot]//[Turi] [Nomi]//[Til]" "[URL]">

Atributlar

Yuqori darajadagi element
Dokumentdagi yuqori darajadagi elementni ko'rsatadi. HTML uchun bu <html> tegi
Oshkoraligi
Dokument oshkora (PUBLIC) yoki sistema resursi (SYSTEM) bo'lishi mumkin. HTML/XHTML uchun PUBLIC qiymati beriladi.
Ro'yxatdan o'tganligi
DTDni ishlab chiquvchi (developer) Standartlash bo'yicha Xalqaro Tashkilot (International Organization for Standardization, ISO)dan ro'yxatdan o'tganligini ko'rsatadi. Ikkita qiymatdan birini qabul qiladi: plyus + — ishlab chiquvchi ro'yxatdan o'tgan, minus - — ishlab chiquvchi ro'yxatdan o'tmagan. W3C uchun "-" qiymati ko'rsatiladi.
Tashkilot
DTDni ishlab chiqqan tashkilot nomi. HTML/XHTMLlar rasman W3C tomonidan nashr qilinadi. Shuning uchun qiymat sifatida W3C ko'rsatiladi.
Turi
Tavsiflanayotgan hujjatning turi. HTML/XHTMLlar uchun DTD ko'rsatiladi.
Nomi
DTDni tavsiflovchi dokument nomi.
Til
Obyeknti tavsifi qaysi til yordamida yozilganligi. HTML/XHTMLlar uchun EN ingliz tili ko'rsatiladi.
URL
DTD dokumentining veb manzili.

Misol

HTML 4.01

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
  "http://www.w3.org/TR/html4/strict.dtd">
<html>
 <head>
   <title>!DOCTYPE</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 </head>
 <body>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
  tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
  quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
  consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
  cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
  proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
 </body> 
</html>

HTML 5

<!DOCTYPE html>
<html>
 <head>
   <title>!DOCTYPE</title>
   <meta charset="utf-8">
 </head>
 <body>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
  tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
  quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
  consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
  cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
  proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
 </body> 
</html>

Eslatma

6-versiyagacha bo'lgan Internet Explorer brauzerlari uchun <!DOCTYPE> dokumentning birinchi qatorida bo'lishi shart. Aks holda brauzer "quirk mode" ga o'tadi.

Brauzerlar

Internet Explorer Edge Chrome Opera Safari Firefox
5 12 1 7 1 1
Android Firefox Opera Safari
1 1 6 1