HTML and CSS Reference
In-Depth Information
Introduce an XHTML DOCTYPE Declaration
Insert an XHTML DOCTYPE declaration at the start of each document.
<html xmlns="">
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="">
The DOCTYPE declaration points to the DTD that is used to resolve entity references. Without it, the only entity
references you can use are &amp; , &lt; , &gt; , &apos; , and &quot; . Once you've added it, though, you can use
the full set of HTML entity references: &copy; , &nbsp; , &eacute; , and so forth.
The DOCTYPE declaration will also be important in the next chapter when we begin to make documents valid,
not merely well-formed.
Potential Trade-offs
Adding an XHTML DOCTYPE declaration has the side effect of turning off quirks mode in many browsers. This
can affect how a browser renders a document. In general, this is a good thing, because nonquirks mode is much
more interoperable. However, if you have old stylesheets that depend on quirks mode for proper appearance,
adding a DOCTYPE may break them. You might have to update them to be standards conformant first. This is
especially true for stylesheets that do very precise layout calculations.
You can use three possible DTDs for XHTML: frameset, transitional, and strict.
The frameset DTD allows pages to contain frames.
The transitional DTD retains deprecated presentational elements such as i , b , u , iframe , and applet .
The strict DTD removes all deprecated presentational elements and attributes that should be replaced with
CSS. It also tightens up the content model of many elements. For instance, in strict XHTML, blockquotes
and bodies cannot contain plain text, only other block-level elements.
These are indicated by one of the following three DOCTYPE declarations:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
Search WWH ::

Custom Search