Knowledge (XXG)

Document type declaration

Source 📝

85:, which is not SGML-based, uses the DOCTYPE only for mode selection. Since web browsers are implemented with special-purpose HTML parsers, rather than general-purpose DTD-based parsers, they do not use DTDs and never access them even if a URL is provided. The DOCTYPE is retained in HTML5 as a "mostly useless, but required" header only to trigger "standards mode" in common browsers. 169:(i.e. the name of the root element that the DTD applies to trees descending from). In XML, the root element that represents the document is the first element in the document. For example, in XHTML, the root element is <html>, being the first element opened (after the doctype declaration) and last closed. 277:
If both an internal DTD subset and an external identifier are included in a DOCTYPE declaration, the internal subset is processed first, and the external DTD subset is treated as if it were transcluded at the end of the internal subset. Since earlier definitions take precedence over later definitions
249:
In XHTML documents, the doctype declaration must always explicitly specify a system identifier. In SGML-based documents like HTML, on the other hand, the appropriate system identifier may automatically be inferred from the given public identifier. This association might e.g. be performed by means of
273:
or add/edit PUBLIC keyword behaviors. It is possible, but uncommon, to include the entire DTD in-line in the document, within the internal subset, rather than referencing it from an external file. Conversely, the internal subset is sometimes forbidden within simple SGML profiles, notably those for
229:
keyword (otherwise) may (and, in XML, must) be followed by a "system identifier" that is likewise enclosed in quotation marks. Although the interpretation of system identifiers in general SGML is entirely system-dependent (and might be a filename, database key, offset, or something else), XML
372:
and its corresponding WHATWG version recommend browsers to only accept XHTML DTDs of certain FPIs and to prefer using internal logic over fetching external DTD files. It further specifies an "internal DTD" for XHTML which is merely a list of HTML entity names.
350:
and, therefore, it is the first tag to be opened after the end of the doctype declaration in this example and the next ones, too. The HTML tag is not part of the doctype declaration but has been included in the examples for orientation purposes.
359:
Some common DTDs have been put into lists. W3C has produced a list of DTDs commonly used in the web, which contains the "bare" HTML5 DTD, older XHTML/HTML DTDs, DTDs of common embedded XML-based formats like
346:. An entity resolver may use either identifier for locating the referenced external entity. No internal subset has been indicated in this example or the next ones. The root element is declared to be 172:
Since the syntax for the external identifier and internal subset are both optional, the document type name is the only information which it is mandatory to give in a DOCTYPE declaration.
1066: 1039: 722:
With the exception of the lack of a URI or the FPI string (the FPI string is treated case sensitively by validators), this format (a case-insensitive match of the string
705:
declaration which is very short, due to its lack of references to a DTD in the form of a URL or FPI. All it contains is the tag name of the root element of the document,
730:. Both in HTML4 and in HTML5, the formal syntax is defined in upper case letters, even if both lower case and mixes of lower case upper case are also treated as valid. 246:. It means that the XML parser must locate the DTD in a system specific fashion, in this case, by means of a URL reference of the DTD enclosed in double quote marks. 942: 381:
Strict DTD does not allow presentational markup with the argument that Cascading Style Sheets should be used for that instead. This is how the Strict DTD looks:
254:
keyword can (except in XML) also be used without a system identifier following, indicating that a DTD exists but should be inferred from the document type name.
214:
quotation marks. The public identifier does not point to a storage location, but is rather a unique fixed string intended to be looked up in a table (such as an
1062: 1050:
3. A string that is an ASCII case-insensitive match for the string "DOCTYPE". 5. A string that is an ASCII case-insensitive match for the string "HTML".
747:". This is because in XHTML syntax all HTML element names are required to be in lower case, including the root element referenced inside the HTML5 186:, following the root element name (and separating syntax such as spaces), but before any internal subset. This begins with either the keyword 1070: 210:
shared only within an organisation). If the PUBLIC keyword is used, it is followed by the public identifier enclosed in double or single
889: 218:); however, in some (but not all) SGML profiles, the public identifier must be constructed using a particular syntax called 1157: 1035: 822: 946: 161:
syntax is followed by separating syntax (such as spaces, or (except in XML) comments opened and closed by a doubled
1095: 238:
and, there are 3 possible system identifiers available for XHTML 1.1 depending on the needs. One of them is the
920: 775: 771: 426: 365: 270: 219: 182: 40: 1010: 637: 338:
This document type declaration for XHTML includes by reference a DTD, whose public identifier is
810: 885: 869: 262:
The last, optional, part of a DOCTYPE declaration is surrounded by literal square brackets (
222:(FPI), which specifies the owner as well as whether it is available to the general public. 1118: 881: 759: 466:
tags are supported and the code must be written correctly according to XML Specification.
278:
in a DTD, this allows the internal subset to override definitions in the external subset.
52: 1129: 906: 967: 804: 807: 69:
perform DOCTYPE "sniffing" or "switching", wherein the DOCTYPE in a document served as
62: 521:
XHTML Transitional DTD is like the XHTML Strict DTD, but deprecated tags are allowed.
1162: 1151: 711: 403:
Transitional DTD allows some older PUBLIC and attributes that have been deprecated:
986:"W3C QA - Recommended list of Doctype declarations you can use in your Web document" 985: 202:, i.e. one shared between multiple computer systems (regardless of whether it is an 1123: 909:. The Organization for the Advancement of Structured Information Standards (OASIS). 636:
XHTML 1.1 is the most current finalized revision of XHTML, introducing support for
576:
XHTML Frameset DTD is the only XHTML DTD that supports Frameset. The DTD is below.
215: 162: 758:
is optional in XHTML5 and may simply be omitted. However, if the markup is to be
1137: 74: 66: 1091: 924: 785: 463: 48: 408:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 1142: 36: 535:"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 434:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" 297:"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 877: 734: 368:
as well as "compound" documents that combine those formats. Both W3C
361: 43:(DTD) (for example, the formal definition of a particular version of 16:
Instruction that associates documents with a document type definition
590:"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> 244:"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" 1126:- an informative (not normative) W3C Quality Assurance publication 698: 688:"http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd"> 672:"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd"> 456: 369: 211: 82: 726:) is the same as found in the syntax of the SGML based HTML 4.01 480:"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 780: 581:<?xml version="1.0" encoding="UTF-8"?> 526:<?xml version="1.0" encoding="UTF-8"?> 471:<?xml version="1.0" encoding="UTF-8"?> 59: 44: 32: 928: 386:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 239: 231: 28: 286:
The first line of a World Wide Web page may read as follows:
250:
a catalog file resolving the FPI to a system identifier. The
651:"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 429:
are used, the Frameset DTD must be used instead, like this:
274:
basic HTML parsers that don't implement a full SGML parser.
532:
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
51:
form of the document, it manifests as a short string of
437:"http://www.w3.org/TR/html4/frameset.dtd"> 344:
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
93:
The general syntax for a document type declaration is:
587:
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
389:"http://www.w3.org/TR/html4/strict.dtd"> 640:. XHTML 1.1 has the stringency of XHTML 1.0 Strict. 459:'s DTDs are also Strict, Transitional and Frameset. 411:"http://www.w3.org/TR/html4/loose.dtd"> 742: 713: 709:. In the words of the specification draft itself: 477:
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
263: 251: 243: 235: 226: 191: 187: 158: 1092:"Polyglot Markup: HTML-Compatible XHTML Documents" 1067:Web Hypertext Application Technology Working Group 1040:Web Hypertext Application Technology Working Group 294:"-//W3C//DTD XHTML 1.0 Transitional//EN" 194:, specifying whether the DTD is specified using a 180:The DOCTYPE declaration can optionally contain an 27:, is an instruction that associates a particular 741:must be a case-sensitive match of the string " 8: 1124:Recommended DTDs to use in your Web document 864: 862: 860: 858: 685:"-//W3C//DTD XHTML Basic 1.1//EN" 669:"-//W3C//DTD XHTML Basic 1.0//EN" 144:<!-- internal subset declarations --> 116:<!-- internal subset declarations --> 856: 854: 852: 850: 848: 846: 844: 842: 840: 838: 605:"http://www.w3.org/1999/xhtml" 550:"http://www.w3.org/1999/xhtml" 495:"http://www.w3.org/1999/xhtml" 330:"http://www.w3.org/1999/xhtml" 234:. For example, the FPI for XHTML 1.1 is 797: 206:available to the general public, or an 340:-//W3C//DTD XHTML 1.0 Transitional//EN 225:The public identifier (if present) or 55:that conforms to a particular syntax. 648:"-//W3C//DTD XHTML 1.1//EN" 236:"-//W3C//DTD XHTML 1.1//EN" 7: 73:determines a layout mode, such as " 14: 1138:Quirks mode and transitional mode 342:and whose system identifier is 760:processed as both XML and HTML 1: 269:. It can be used to add/edit 925:"Comparison of SGML and XML" 905:Walsh, Norman (2001-08-06). 762:, a DOCTYPE should be used. 77:" or "standards mode". The 1179: 1063:"The XHTML syntax ― HTML5" 1132:- another overview table 1096:World Wide Web Consortium 1036:"The HTML syntax ― HTML5" 943:"The DOCTYPE Declaration" 823:"The HTML syntax ― HTML5" 35:document (for example, a 21:document type declaration 772:Document type definition 682:<!DOCTYPE html PUBLIC 679: 666:<!DOCTYPE html PUBLIC 663: 645:<!DOCTYPE html PUBLIC 642: 578: 523: 468: 431: 405: 383: 291:<!DOCTYPE html PUBLIC 288: 220:Formal Public Identifier 126: 95: 41:document type definition 931:. NOTE-sgml-xml-971215. 208:unavailable public text 138:"/quotedURI/" 110:"/quotedURI/" 107:"/quotedFPI/" 720: 694:HTML5 DTD-less DOCTYPE 230:requires that they be 1119:HTML Doctype overview 968:"DOCTYPE Declaration" 744:<!DOCTYPE html> 718:, case-insensitively. 715:<!DOCTYPE html> 462:XHTML Strict DTD. No 204:available public text 1015:html.spec.whatwg.org 870:Goldfarb, Charles F. 638:XHTML Modularization 198:identifying it as a 1158:XML-based standards 183:external identifier 176:External identifier 1143:Box model tweaking 972:msdn.microsoft.com 167:document type name 153:Document type name 1134: 874:The SGML Handbook 584:<!DOCTYPE html 529:<!DOCTYPE html 474:<!DOCTYPE html 265:), and called an 196:public identifier 165:), followed by a 81:serialization of 1170: 1133: 1106: 1105: 1103: 1102: 1088: 1082: 1081: 1079: 1078: 1069:. Archived from 1059: 1053: 1052: 1047: 1046: 1032: 1026: 1025: 1023: 1021: 1007: 1001: 1000: 998: 996: 982: 976: 975: 964: 958: 957: 955: 954: 945:. Archived from 939: 933: 932: 917: 911: 910: 902: 896: 895: 866: 833: 832: 830: 829: 819: 813: 802: 757: 750: 746: 745: 740: 729: 725: 717: 716: 708: 704: 689: 686: 683: 677:XHTML Basic 1.1 673: 670: 667: 661:XHTML Basic 1.0 657:XHTML Basic DTDs 652: 649: 646: 627: 624: 621: 618: 615: 612: 609: 606: 603: 600: 597: 594: 591: 588: 585: 582: 572: 569: 566: 563: 560: 557: 554: 551: 548: 545: 542: 539: 536: 533: 530: 527: 517: 514: 511: 508: 505: 502: 499: 496: 493: 490: 487: 484: 481: 478: 475: 472: 447: 444: 441: 438: 435: 421: 418: 415: 412: 409: 399: 396: 393: 390: 387: 349: 345: 341: 334: 331: 328: 325: 322: 319: 316: 313: 310: 307: 304: 301: 298: 295: 292: 264: 253: 245: 237: 228: 193: 189: 160: 148: 145: 142: 139: 136: 133: 130: 120: 117: 114: 111: 108: 105: 102: 99: 80: 72: 1178: 1177: 1173: 1172: 1171: 1169: 1168: 1167: 1148: 1147: 1115: 1110: 1109: 1100: 1098: 1090: 1089: 1085: 1076: 1074: 1061: 1060: 1056: 1044: 1042: 1034: 1033: 1029: 1019: 1017: 1011:"HTML Standard" 1009: 1008: 1004: 994: 992: 984: 983: 979: 966: 965: 961: 952: 950: 941: 940: 936: 919: 918: 914: 904: 903: 899: 892: 882:Clarendon Press 868: 867: 836: 827: 825: 821: 820: 816: 803: 799: 794: 768: 755: 748: 743: 738: 727: 723: 714: 706: 702: 696: 691: 690: 687: 684: 681: 675: 674: 671: 668: 665: 659: 654: 653: 650: 647: 644: 634: 629: 628: 625: 622: 619: 616: 613: 610: 607: 604: 601: 598: 595: 592: 589: 586: 583: 580: 574: 573: 570: 567: 564: 561: 558: 555: 552: 549: 546: 543: 540: 537: 534: 531: 528: 525: 519: 518: 515: 512: 509: 506: 503: 500: 497: 494: 491: 488: 485: 482: 479: 476: 473: 470: 454: 449: 448: 445: 442: 439: 436: 433: 423: 422: 419: 416: 413: 410: 407: 401: 400: 397: 394: 391: 388: 385: 379: 357: 347: 343: 339: 336: 335: 332: 329: 326: 323: 321:"ltr" 320: 317: 314: 311: 308: 305: 302: 299: 296: 293: 290: 284: 267:internal subset 260: 258:Internal subset 190:or the keyword 178: 155: 150: 149: 146: 143: 140: 137: 134: 131: 128: 122: 121: 118: 115: 112: 109: 106: 103: 100: 97: 91: 78: 70: 17: 12: 11: 5: 1176: 1174: 1166: 1165: 1160: 1150: 1149: 1146: 1145: 1140: 1135: 1127: 1121: 1114: 1113:External links 1111: 1108: 1107: 1083: 1054: 1027: 1002: 977: 959: 934: 923:(1997-12-15). 912: 907:"XML Catalogs" 897: 890: 834: 814: 796: 795: 793: 790: 789: 788: 783: 778: 767: 764: 695: 692: 680: 664: 658: 655: 643: 633: 630: 623:"en" 614:"en" 579: 568:"en" 559:"en" 524: 513:"en" 504:"en" 469: 453: 452:XHTML 1.0 DTDs 450: 432: 406: 384: 378: 377:HTML 4.01 DTDs 375: 356: 353: 312:"ar" 289: 283: 280: 259: 256: 177: 174: 154: 151: 127: 96: 90: 87: 63:layout engines 45:HTML 2.0 - 4.0 15: 13: 10: 9: 6: 4: 3: 2: 1175: 1164: 1161: 1159: 1156: 1155: 1153: 1144: 1141: 1139: 1136: 1131: 1128: 1125: 1122: 1120: 1117: 1116: 1112: 1097: 1093: 1087: 1084: 1073:on 2012-06-18 1072: 1068: 1064: 1058: 1055: 1051: 1041: 1037: 1031: 1028: 1016: 1012: 1006: 1003: 991: 987: 981: 978: 973: 969: 963: 960: 949:on 2011-08-14 948: 944: 938: 935: 930: 926: 922: 916: 913: 908: 901: 898: 893: 891:0-19-853737-9 887: 883: 879: 875: 871: 865: 863: 861: 859: 857: 855: 853: 851: 849: 847: 845: 843: 841: 839: 835: 824: 818: 815: 812: 809: 806: 801: 798: 791: 787: 784: 782: 779: 777: 773: 770: 769: 765: 763: 761: 752: 736: 731: 724:!DOCTYPE HTML 719: 710: 700: 693: 678: 662: 656: 641: 639: 632:XHTML 1.1 DTD 631: 577: 522: 467: 465: 460: 458: 451: 430: 428: 404: 382: 376: 374: 371: 367: 363: 354: 352: 287: 281: 279: 275: 272: 268: 257: 255: 247: 241: 233: 223: 221: 217: 213: 209: 205: 201: 197: 185: 184: 175: 173: 170: 168: 164: 152: 125: 94: 88: 86: 84: 76: 68: 64: 61: 56: 54: 50: 46: 42: 38: 34: 30: 26: 22: 1130:DOCTYPE grid 1099:. Retrieved 1086: 1075:. Retrieved 1071:the original 1057: 1049: 1043:. Retrieved 1030: 1018:. Retrieved 1014: 1005: 993:. Retrieved 989: 980: 971: 962: 951:. Retrieved 947:the original 937: 921:Clark, James 915: 900: 873: 826:. Retrieved 817: 800: 774:contains an 753: 732: 721: 712: 697: 676: 660: 635: 575: 520: 461: 455: 424: 402: 380: 358: 337: 285: 276: 266: 261: 248: 224: 216:SGML catalog 207: 203: 199: 195: 181: 179: 171: 166: 163:ASCII hyphen 159:<!DOCTYPE 157:The opening 156: 132:root-element 129:<!DOCTYPE 123: 101:root-element 98:<!DOCTYPE 92: 67:web browsers 57: 24: 20: 18: 355:Common DTDs 200:public text 75:quirks mode 1152:Categories 1101:2012-01-17 1077:2009-09-01 1045:2011-06-05 990:www.w3.org 953:2011-09-09 828:2011-06-05 792:References 786:XML schema 464:deprecated 242:reference 65:in modern 49:serialized 47:). In the 79:text/html 71:text/html 39:) with a 1020:22 March 995:22 March 872:(1990). 766:See also 608:xml:lang 553:xml:lang 498:xml:lang 271:entities 37:web page 776:example 756:DOCTYPE 749:DOCTYPE 739:DOCTYPE 728:DOCTYPE 703:DOCTYPE 701:uses a 282:Example 25:DOCTYPE 888:  878:Oxford 735:XHTML5 427:frames 362:MathML 252:SYSTEM 227:SYSTEM 192:PUBLIC 188:SYSTEM 135:SYSTEM 104:PUBLIC 89:Syntax 53:markup 811:HTML4 808:HTML3 805:HTML2 699:HTML5 599:xmlns 544:xmlns 489:xmlns 457:XHTML 370:HTML5 324:xmlns 212:ASCII 147:]> 119:]> 83:HTML5 23:, or 1163:SGML 1022:2019 997:2019 886:ISBN 781:RDFa 754:The 737:the 707:HTML 626:> 617:lang 596:html 593:< 571:> 562:lang 541:html 538:< 516:> 507:lang 486:html 483:< 446:> 443:html 440:< 420:> 417:html 414:< 398:> 395:html 392:< 364:and 348:html 333:> 306:lang 303:html 300:< 232:URIs 60:HTML 58:The 33:SGML 929:W3C 751:. 733:In 425:If 366:SVG 315:dir 240:URL 124:or 31:or 29:XML 1154:: 1094:. 1065:. 1048:. 1038:. 1013:. 988:. 970:. 927:. 884:. 880:: 876:. 837:^ 19:A 1104:. 1080:. 1024:. 999:. 974:. 956:. 894:. 831:. 620:= 611:= 602:= 565:= 556:= 547:= 510:= 501:= 492:= 327:= 318:= 309:= 141:[ 113:[

Index

XML
SGML
web page
document type definition
HTML 2.0 - 4.0
serialized
markup
HTML
layout engines
web browsers
quirks mode
HTML5
ASCII hyphen
external identifier
ASCII
SGML catalog
Formal Public Identifier
URIs
URL
entities
MathML
SVG
HTML5
frames
XHTML
deprecated
XHTML Modularization
HTML5
XHTML5
processed as both XML and HTML

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.