Skip to content
GO Soft Logo
Global Opportunities with online Software

W3C Doctypes

A doctype (Document Type Declaration) should be included at the top of xhtml code above the <html> tag. It is used by validators such as the W3C XHTML/HTML validator to determine the rules to use when validating source code. It informs the validator which version of XHTML/HTML is being used, and is a key component of modern compliant web pages.

W3C Doctypes Quick Jump

Why Specify A Doctype?

Modern browsers use the doctype to decide whether to display the web page in Quirks mode or Standards mode and inform the validator which version of XHTML/HTML is being used. Doctypes are a key component of compliant web pages. Markup and CSS will not validate without them.

Tools such as a markup validator use the doctype to check the syntax of the XHTML/HTML. Errors can then be found that may affect the way the page is rendered by the browser. These tools do not work if they do not know what kind of web page it is.

The doctype declaration will remove unnecessary guessing by the browser. It will trigger the standard parsing mode and make the display of the web page faster, consistent and free of any nasty surprises.

Quirks Mode vs. Standards Mode

Using an incomplete or outdated doctype, or no doctype at all, puts browsers into Quirks mode.

Quirks mode refers to a technique used by some web browsers to maintain backward compatibility with web pages designed for older browsers, where the browser assumes old-fashioned invalid markup as per the industry norms of the late 1990s.

In Quirks mode, the browser will attempt to parse the page in backward-compatible fashion, rendering the CSS as it might have looked in IE4, and reverting to a proprietary, browser-specific DOM.

This is not what we want, but it is often what we get where a correct doctype is not used.

So be sure to use a correct doctype so that the browser can render your page in the way that you intended.

What Do Doctypes Look Like?

GO Soft uses the XHTML 1.0 Strict doctype, and this is what it looks like:

Below is a list of doctypes which, when used, will put modern browsers into 'Standards' mode.

HTML 4 Transitional

Supports all attributes of HTML 4, presentational attributes, deprecated elements and link targets. It should be used for webpages that are transitioning to HTML 4 strict.

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

HTML 4 Strict

A trimmed down version of HTML 4 with an emphasis on structure over presentation. Deprecated elements and attributes (including most presentational attributes), frames and link targets are not allowed. CSS should be used to style all elements.

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

HTML 4 Frameset

Identical to Transitional above, except for the use of <frameset> over <body>

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

HTML 5 Doctype

HTML 5 recommends the use of the very simple doctype <!DOCTYPE HTML> and suggests that doctypes are headers that, although required, are mostly useless. A doctype should ensure that browsers render web pages in the correct, standards compliant mode and the above doctype will do that, including in IE8. For future proofing your web pages, this may be the doctype to go with.

<!DOCTYPE HTML>

XHTML 1.0 Transitional

Use so that your webpage conforms to basic XHTML rules, but still uses some HTML presentational tags for the sake of viewers that do not support CSS.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

XHTML 1.0 Strict

Use so that your webpage conforms to XHTML rules and uses CSS for full separation between content and presentation.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

XHTML 1.0 Frameset

Identical to Transitional above, except for the use of <frameset> over <body>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

XHTML 1.1 Doctype

The XHTML 1.1 document type is a fully functional document type with rich semantics. It does not contain any of the deprecated functionality of XHTML 1.0 or HTML 4. Despite these exceptions, or perhaps because of them, the XHTML 1.1 doctype is a solid basis for future doctypes that are targeted at varied user agent environments.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Validate Your Source Code

Visit the W3C Validator and validate your source code.

There are Three Ways to Validate Your Source Code

  • Validate by URL
  • Validate by File Upload
  • Validate by Direct Input

The doctype will drive how the validator checks your source code. Any code that fails to meet the required standard will generate an error message which will help you to make corrections until your code validates.

World Wide Web Consortium

GO Soft
Challenges
Developer Zone
Portfolio
Today

Valid XHTML 1.0 Strict
Valid CSS
Powered by PHP
Mozilla
RSS 2.0 Feeds