HTML and CSS Reference
In-Depth Information
Introduce a Strict DOCTYPE Declaration
Insert the XHTML strict DOCTYPE declaration at the start of each document.
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
Motivation
The strict DTD removes deprecated presentational elements such as b , i , and center . You can replace these
with semantic elements such as em and strong and CSS styles. This will make your meaning clearer.
It also enables you to move the style information fully into CSS. This reduces bandwidth and makes it much
easier to lay out a page, because the markup is not competing with the stylesheet.
Potential Trade-offs
The strict DTD is extremely limiting. A lot of elements and attributes you've been accustomed to using are no
longer allowed. Some changes that may be required involve substantial manual effort.
The counterbalance is that web browsers do not require validity. It is OK to serve documents with the strict DTD
even if they still use deprecated elements such as b , i , and iframe . It is OK to have text that is not enclosed in
a paragraph. Such documents are not valid, but browsers can handle them. You can gradually increase your
conformance by making a series of small changes as time permits.
Mechanics
The first change you need to make is to point to the strict DTD from the DOCTYPE declaration:
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
If you've already made your documents valid against the transitional DTD, this is a simple search and replace.
Search for -//W3C//DTD XHTML 1.0 Transitional//EN and replace it with -//W3C//DTD XHTML 1.0
Strict//EN . Then search for xhtml1-transitional.dtd and replace it with xhtml1-strict.dtd .
Tidy defaults to the transitional DTD when run in XHTML mode, but you can ask it for strict instead using the --
doctype option:
$ tidy -asxhtml --doctype strict example.html
Search WWH ::




Custom Search