The Original Web-Wise-Wizard
Web Authors, Web Developers and Webmasters Internet Toolbox
Best viewed at 1024 x 768 using a colour depth greater than 256

SGML (HTML) Doctype Directives Examples

 

Doctype Directives?

You will often look at an HTML document (a web page) and see a Doctype Directive on the first line of the document. Many web authors do not understand the meaning of these directives and many HTML documents found on the Web either display an incorrect directive or no directive at all. You also find some HTML documents that contain a valid Doctype Directive but when you try to validate the document you find that the document will not validate against the version of HTML stipulated in the Directive.

A Doctype Directive is an SGML (Standard Generalized Markup Language) construct that identifies the document type as being HTML (Hyper-text Markup Language). It can also specify which version of HTML the document is compliant with and it can also specify different levels of compliance.

The HTML standard states that every HTML document requires a document type declaration, to tell web browsers, Web robots, HTML validators and other user agents, which version of HTML to use when parsing the document (interpreting the syntax). This allows the HTML language to grow and develop over time without causing confusion among the different versions of HTML. It also enables you to use HTML validators to check the structure and syntax of your HTML document.

Some Terms Explained ...

  • DTD  (Document Type Definition). DTD is the definition of a document type in SGML, consisting of a set of mark-up tags and their interpretation.
  • HTML  (Hypertext Markup Language). A Hypertext document format used on the World-Wide Web that is built on top of SGML. "Tags" are embedded in the text. A tag consists of a "<", a "directive" (case insensitive), zero or more parameters and a ">". Matched pairs of directives, like "<TITLE>" and "</TITLE>" are used to delimit text which is to appear in a special place or style.
  • IETF (Internet Engineering Task Force). The IETF is charged with developing and promoting Internet standards. It is an open, all-volunteer organization, with no formal membership nor membership requirements.
  • SGML  (Standard Generalized Markup Language). A generic markup language for representing documents. SGML is an International Standard that describes the relationship between a document's content and its structure. SGML allows document-based information to be shared and re-used across applications and computer platforms in an open, vendor-neutral format. SGML is sometimes compared to SQL, in that it enables companies to structure information in documents in an open fashion, so that it can be accessed or re-used by any SGML-aware application across multiple platforms.
  • W3C  (World Wide Web Consortium). W3C is the main standards BODY for the World-Wide Web. W3C works with the global community to establish international standards for client and server protocols that enable on-line commerce and communications on the Internet. It also produces reference software.
  • XHTML (Extensible Hypertext Markup Language). A reformulation of HTML 4.01 in XML. Being XML means that XHTML can be viewed, edited, and validated with standard XML tools. At the same time, it operates as well as or better than HTML 4 in existing HTML 4 conforming user agents.

Currently Used Examples ...

You should place a Doctype Directive right at the beginning of each of your HTML documents (web pages). Doctype Directives are not necessarily standard and you can use a custom DTD if you have some special requirements but we suggest that you use the examples we have recommended below unless you have a specific reason for doing otherwise.

If you are new to Doctype Directives then we suggest that you start by using the HTML 4.01 Transitional directive ...

HTML 4.01 Examples

an HTML 4.01 Strict example ...

This is the HTML 4.01 Strict DTD, which excludes the presentation attributes and elements that W3C expects to phase out as support for style sheets matures. Authors should use the Strict DTD when possible.

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

an HTML 4.01 Transitional example ...

This is the Transitional DTD, which includes support for presentation attributes and elements but W3C expects to phase this DTD out as support for style sheets matures. This DTD should be used when support for presentation attribute and elements is required.

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

an HTML 4.01 Frameset example ...

This DTD is identical to the HTML 4.01 Transitional DTD except the "FRAMESET" element replaces the "BODY" element.

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

XHTML 1.0 Examples

an XHTML 1.0 Strict example ...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
</html>

an XHTML 1.0 Transitional example ...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
</html>

an XHTML 1.0 Frameset example ...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
 
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
</html>

XHTML 1.1 Example

there are no seperate Strict, Transitional or Frameset directives in XHTML 1.1 ...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 
<html xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
</html>

Document Validation ...

From the web authors point of view one of the primary reasons for including a Doctype Directive at the start of HTML documents is so that they can validate their HTML documents. Validation means checking the structure and syntax of documents against the version of HTML (or XHTML) stipulated in the Doctype Directive and documents can be validated using the W3C HTML Markup Validator. This is a free, on-line service that can be used by anyone and you can either stipulate the Web Address of your document or upload the page directly from your hard-drive. You will find a link to the W3C Markup Validator at the bottom of this page.

Very few of us write perfect web pages and the Markup Validator provides a list of errors if the document does not validate. You work your way through the list, correcting the errors and then re-validating your document and you will probably have to repeat the process several times before the page will validate. However, the upside to this process is that it is a very effective way of learning to write correct HTML Markup and you will soon get used to using the validator.

Character Set ...

When you come to validate your HTML documents there is one other item of information that you will need to include in your page Markup. This is a META Tag declaring the character set you are using so that validation and Accessibility testers know which character set to test your pages by. I do not pretend any great expertise in this subject but we develop our HTML documents on a Microsoft Windows system and the following META Tag declaration works without any problems. The character set declaration is likely to be different on other platforms such as Apple Macintosh, Unix, etc.

locate META Tags in the HEAD section of your web page ...

<meta http-equiv="Content-type" content="text/html; charset=ISO-8859-1">

Transitional URLs Warning ...

Have you encountered a situation where your CSS positioning works as you expect it to in Microsoft browsers but exhibits different behaviour in non-Microsoft browsers (e.g. Firefox, Mozilla, Opera, Netscape, etc.)?  If this is the case then the cause of the problem could lie with the W3C HTML 4.01 Transitional Doctype Directive you are using. There are different URLs for the Transitional Directive and I have displayed the two Directives that I know about here.

this "Transitional" works well in all browsers I have tested ...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">

this "Transitional" only works properly in Microsoft browsers ...

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

It has become obvious that using the correct URL in a Transitional Doctype Directive is all important when developing cross-browser pages and I would be embarrassed to admit how long I spent grappling with CSS positioning problems in non-Microsoft browsers. However, using the correct Directive will not resolve all CSS positioning problems and you will probably have to wait for the introduction of CSS3 before that happens.

Depreciated Examples ...

We have included this selection of Doctype Directives which, in the context of developing new web pages, should now be classified as depreciated. Even so, the W3C validator will still validate web pages based on these directives. The really interesting thing about these historical examples is that they highlight the length of time that W3C standards for writing web pages have existed.

an HTML 4.0 Strict directive ...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">

an HTML 4.0 Transitional directive ...

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

an HTML 4.0 Frameset directive ...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN" "http://www.w3.org/TR/REC-html40/frameset.dtd">

an HTML 3.2 Transitional directive ...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 TRANSITIONAL//EN">

an HTML 3.2 Final directive ...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 FINAL//EN">

an HTML 3.2 directive ...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">

an HTML 2.0 directive ...

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

Link Directly To This Page ...

help support free information on the Internet ...

Many users prefer to link directly to individual content pages on Web-Wise-Wizard. If you would like to do this then we have provided the following HTML/CSS link script which you can copy and paste directly into your HTML editor. Alternatively, you might like to use our New Dynamic Link Generator to create a link that more fully meets your own particular requirements.

the link displayed ...

Web-Wise-Wizard - HTML Doctype Directives A Doctype Directive is an SGML construct that identifies the document type as HTML. The Directive also specifies the version of HTML and the level of compliance that the document is compliant with.

select/copy the link Markup ...

Featured Tutorial
Want More Traffic? Increase your Link Popularity and your PageRank by learning how to use Web Directories
Link To Us Scripts
New Dynamic Link Generator
 
If you find this page interesting or useful then others are likely to view it in exactly the same way. Providing a link to the page will be considered by the search engines as casting a vote for the page. In turn, this will help to improve the search engine ranking of the page resulting in more people being able to see the page. Your link really does count so please don't delay.
 
Post your link NOW!
 
 
SGML Doctype Links
 
 
 
 
 
Copyright © 1998,2014, Gilbert Hadley, Liverpool, England