The DOCTYPE declaration (DTD) statement is a top-level tag-like reference known as a Public Text Identifier. It should appear at the very beginning of an HTML/XHTML document in order to identify the content of the document as conforming to a particular HTML DTD specification. Historically, including a DTD was not required by browsers. They just blindly interpreted a document according to what elements and attributes were understood. But that has now changed. Every web page you create should now have a DOCTYPE declaration statement.
The quoted segment within a DOCTYPE declaration is called a Formal Public Identifier (FPI.) Every distinct DTD variation will have its own unique FPI string. A DOCTYPE declaration statememt will look something like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Note that the DTD is contained in brackets like an HTML tag and begins with !DOCTYPE -- an exclamation mark followed by the word doctype all in uppercase letters. The elements of the DTD are separated from each other by a single space. The individual parts of these elements can be referenced as shown here:
<!DOCTYPE [Top Element] [Availability] "[Registration]//[Organization]//[Type] [Label]//[Language]" "[URL]">
- Note: a pair of forward slash characters "//" is used as delimiters between keyword fields
- [Top Element] - indicates top level element, for HTML it is HTML.
- [Availability] - indicates if publicly accessible (PUBLIC) or system resource (SYSTEM)
- [Registration] - organization name is "+" ISO-registered or "-" not registered
- Note: IETF and W3C are not registered ISO organizations and thus uses "-"
- [Organization] - indicates organization responsible for creation/maintenance of source
- Note: IETF and W3C are the two originating organizations of official HTML/XHTML
- [Type] - Public Text Class, ie: type of object referenced - for HTML/XHTML DTD it is "DTD"
- [Label] - Public Text Description, ie: unique descriptive name for DTD being referenced
- [Language] - Public Text Language, ie: the natural language encoding system used
- Note: ISO 639 language code (uppercase, 2 letters.) HTML/XHTML is English "EN"
- [URL] - optional explicit URL to the DTD being referenced
The Internet, in particular the World Wide Web now has a huge legacy of existing content. There are untold millions of web pages on web servers all over the planet. These pages were created at different times, many before the current web standards were in place. Many of these pages were written by authors that were not aware of what the correct syntax or standards actually were. Many of these authors had (and still have!) a tendency to code pages and test the result in a single browser without validating their code. In the past the various browsers had many behaviors that did not comply with the W3C standards either.
Many of the pages on the web actually rely on some of these buggy or non-standards behaviors. You've seen pages that say something like, "Best viewed with..." and then name a particular browser. Web designers should code to a standard, not to a browser! And so, now that the W3C standards receive more and more attention, and the browsers have become more compliant with these evolving standards, a big problem has arisen.
Old browsers would just read whatever page that was thrown at it and try to render it as best they could, including any proprietary browser extensions they understood. If a new browser version was to move to a strictly standards-compliant rendering behavior, millions of pages on the web would instantly fail to render as inteneded by the author. The standards, however, are gigantic leap forward in web page structure and organization. So do we just continue to accept the non-standard mess of the past or do we move forward to a better way? Enter the DOCTYPE declaratin statement.
Beginning with the Macintosh version of Internet Explorer 5.0 in March 2000 all the major browsers now support the DTD to some degree. To allow for the huge amount of legacy documents as well as all current, and new, standards-based documents, browsers now pay attention to the DOCTYPE declaration statement at the beginning of any HTML/XHTML document. Depending on which DOCTYPE declaration statement is used, the browser will either attempt to render the document as close as possible to the W3C standard indicated or use the legacy rendering behavior that many older pages rely on. These two rendering modes are referred to generally as "standards mode" and "quirks mode" respectively.
It is, therefore, important to specify the correct DOCTYPE declaration statement for the level of coding your page includes. Search engines may reference the DOCTYPE declaration statement in order to determine the validity of your page coding. Some believe the properly coded pages index better. It is certain that incorrectly coded pages that cause the search engine spider to fail to read the page will not be indexed properly.
Discover more from Ultimate Virtual Solutions
Subscribe to get the latest posts sent to your email.