Syntax of a doctype tag

The first thing to notice about a doctype tag it is always the first tag in a document. It goes on the first line before the <html> tag. This is because it has to be the first element that the browser processes. It would not be possible to suddenly change the doctype once the browser had begun to work out how to render the page.

Below is the doctype declaration for html 4.01 transitional.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
	"http://www.w3.org/TR/html4/loose.dtd">

The structure of the tag is also different to all other html tags. The very first thing to notice is that the tag begins with a exclamation mark (!). This is technically as it is a xml processor statement not a html tag at all.

Next comes the word DOCTYPE this must be in upper case. next comes the section declaring which version of html you are going to use using. Typically this might look like

HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

taken from the beginning this declared the document to be html and then the quoted section tells the browser which version of html the document conforms to, in this case html 4.01 transitional. This is done by specifying which DTD the browser is to use when rendering the document. In other words the exact rules for each tag within the document.

The next section of the tag is unique. There now follows a line break and a tab. This is not seen in any other html tag. On this new line there should be a url for the dtd. This further ensures that the browser renders the document correctly. Some browsers contain a "internal" version of the various dtds but these may differ from the W3Cs definitions. If the browser is standards compliant this final section should ensure that the correct W3C dtd is used.

This two part mechanism means that if new types of xml based document are produced it should then be possible to tell a browser how to deal with them through a doctype declaration

Not all doctype declarations have the url element. This is because they refer to a dtd that is standard across all browsers. For instance the doctype for html 2.0 is

<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">

also note the differences in the capitalization and that the document was not produced by the W3C.

previous | next

Creative Commons License
This work is licensed under a Creative Commons License.

Features

Page styles

contact the author

rob cornelius can be contacted here

\n100 top broadway musicals history 101 airborne world war two history apha phi alpha history appalachain mountain history apple g4 aluminum powerbook history apple ii history applebee's international stock market history applebutter history appraisal form history arab american history month archaeology ancient history bay view foods employee history beautiful brown eyes lyrics history bed design history bedford city schools history beer america history sources behrmann family history belize flag history bellpepper history belpre school history belver history beowulf history bible chronicle time line history bible history book bible history compiled bibliography history art big stone power plant history bighorn golf history bigpond history shippensburg pa bilbrough yorkshire england family history bill cosby in african american history biographies and women's history biosphere ii history bipolar disease history birmingham street names history birthday this day in history black dealth plague and history black forest culture history black history articles submit black history cotten gin black history events tulsa black history facts today black history helpers black history mathematics black history month and programs black history month book signing black history month chris black history month crafts black history month links black history month script black history month tampa fl black history month wedquest black history t shirt black history timeline south carolina british royal family history british theatre history 1950-1980 british virgin islands history broken buildings pennsylvania history brookley field history brooks bristol family history broomhead family history brown bess musket history browser erase history budd manufacturing company and philadelphia history buddha in history buffalo blizzards soccer history bullock museum of texas history bunn coffee history chronilogical history timeline chronological history of boston police development chrysler pt cruiser classic history chum radio history church history christian writings apocryphal g cincinnati brewery history cincinnati state parking history cinco de mayo history circa history guild atlanta city of shrewsbury mo history ciudad de m xico city history civil union history civil war history in england clear history on your computer clear internet explorer history list clendenin family history cleopatra vii history clep social sciences history climax blues band concert history clonidine history closing stock price history clp vs dollar history cluster family history clymer route 286 history cmc history cnc lathe history coates family history lewes brighton code of arms history coeur d alene indian history cold war's short history coles kisha history college band history college sports and commercialism and history colombia weather history connelly springs nc history content managemnet system history credit history online order report crimea history crsc award history by disability percentage ct marines connect history included interested dr straun history dread locks history drive through history history international