A.3 Basic Tags^579
XHTML uses the idattribute to configure bookmarks and named fragment
identifiers.
- The Web page document should declare the character encoding. The W3C recom-
mends that the Web page code begin with an XML declaration as follows:
<?xml version="1.0" encoding="UTF-8"?>
However, in practice, some browsers (such as Internet Explorer 6) experience dis-
play issues when a Web page includes an XML declaration. So, the workaround
(which still passes W3C XHTML validation) is to indicate the character encoding
with a metatag in the header section as shown below:
- If provided, the XML declaration should be followed with a Document Type
Definition (DTD). Otherwise, the document should begin with a DTD. There are
three DTDs: strict, transitional, and frameset. The strict DTD is not usually used
by commercial Web sites because it requires the exclusive use of CSS and does not
allow deprecated elements. Use the transitional DTD for most XHTML Web page
documents. Use the Frameset DTDfor Web page documents that describe a
frameset. For more information see Table A.1. - The root element (immediately after the DTD) must be an tag that refers
to the XML namespace and indicates the language, as shown in the following
example:
A.3 Basic Tags
The XML Declaration
<?xml version="1.0" encoding="UTF-8"?>
This XML declaration indicates that the document is based on the XML 1.0 standard.
It also indicates that the character encoding (the internal representation of letters,
numbers, and symbols) used by this document is UTF-8, a form of Unicode. This XML
Table A.1 XHTML document type definitions
DTD Description
XHTML 1.0
Transitional
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml 1 /DTD/xhtml 1 -transitional.dtd">
This is the least strict specification for XHTML 1.0. It allows the use of both CSS and traditional
formatting instructions such as fonts. This DTD is used for most of the coding in this text.
XHTML 1.0
Strict
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml 1 /DTD/xhtml 1 - Strict.dtd">
Requires exclusive use of CSS. Does not allow any deprecated elements.
XHTML 1.0
Frameset
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml 1 /DTD/xhtml 1 -frameset.dtd">
Required for pages using XHTML frames.
Note: In the Description column of this table, the number one (1) is set bold where it might otherwise be confused
with the letter โel.โ