About using a Strict vs. Transitional DOCTYPE in HTML

From Aptana

This page discusses the difference in coding an XHTML file with a Strict DOCTYPE vs. a Transitional DOCTYPE.

Contents

Introduction

If you are using XHTML to code a web page, you have a choice between using a Strict or a Transitional DOCTYPE. The Strict DOCTYPE means that your XHTML has to be completely standards-compliant. The Transitional DOCTYPE allows you to use some elements and attributes that were common in older HTML markup but that do not adhere to current standards.

The Reference section of this Help topic lists the elements and attributes that are allowed by the Transitional DOCTYPE but not by the Strict DOCTYPE for XHTML.

How to Switch from HTML to XHTML

Go to Window -> Preferences -> Aptana -> Editors -> HTML. Change the default extension to ".xhtml". Apply the following "Initial HTML file Contents":

XHTML 1.0 Strict

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Untitled Document</title>
</head>
<body>
	
</body>
</html>

XHTML 1.0 Transitional

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Untitled Document</title>
</head>
<body>
	
</body>
</html>

XHTML 1.1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Untitled Document</title>
</head>
<body>
	
</body>
</html>

Reference

In general, most of the differences between using a Transitional and a Strict DOCTYPE have to do with the guideline that with a Strict DOCTYPE, all presentation information should be in CSS, not in the XHTML markup.

Elements allowed with a Transitional but not Strict DOCTYPE

  • center
  • font
  • iframe
  • strike
  • u

Attributes allowed with a Transitional but not Strict DOCTYPE

  • align - With Strict, align is still allowed on the following table elements:
    • col
    • colgroup
    • tbody
    • td
    • tfoot
    • th
    • thead
    • tr
  • alink
  • background
  • bgcolor
  • border - With Strict, border is still allowed on table element.
  • height - With Strict, height is still allowed on img and object.
  • hspace
  • language
  • link
  • name - name is allowed in HTML 4.01 Strict, but not allowed on form and img in XHTML 1.0 Strict.
  • noshade
  • nowrap
  • target
  • text
  • vlink
  • vspace
  • width - With Strict, width is allowed on img, object, table, col, and colgroup.

Related Topics