14 Lesson 2
FIGURE 2.2 My First Web Page as it appears in the Internet
Explorer browser. Notice that the Title bar contains the text
between the
<title> and </title> tags and the body of the
browser contains the text between the
<body> and </body> tags.
Tip Although you don’t see them, HTML commands
are sitting behind the scenes of every document that
you open in your Web browser. You can see the HTML
commands by selecting Source from the View menu of
Internet Explorer (other browsers might use different
menu commands). When you find a page on the Web
that you like, you can view the source code to learn
how you can use HTML to create something similar.
Caution Some Web pages use frames to display more
than one HTML page at the same time. (See Lesson
10, “Creating Frames.”) To view the source code for
this type of page, make sure that you use your mouse
to highlight some portion of the page you’re inter-
ested in before selecting Source from the View menu.
XHTML Requirements
XHTML, the latest revision of HTML, adds another required element to
your Web pages: the
<!DOCTYPE> tag. This tag appears at the top of the
file and identifies the file as an HTML document conforming to the
XHTML requirements. If you were to create an XHTML-conforming doc-
ument, it would look like the following:
15Creating Your First Page
<!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”
xml:lang=”en” lang=”en”>
<head>
<title>My XHTML Page</title>
</head>
<body>
<p>This is my first XHTML page.</p>
</body>
</html>
The <!DOCTYPE> tag has three variations: Strict, Transitional, and
Frameset. You declare which one you are using in the top of the file.
Strict Declare this variation when you are certain that your
viewers will be accessing your pages from newer browsers that
interpret style sheets correctly. You’ll learn more about style
sheets in Lesson 5, “Adding Your Own Style.” The Strict varia-
tion looks like this:
<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
Transitional Declare this variation when you are not certain
how your viewers will be accessing your pages.
<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd”>
Frameset Declare this variation when you are working in
frames. You will learn more about frames in Lesson 10.
<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-
frameset.dtd”>
16 Lesson 2
You might have noticed one more change from the HTML required ele-
ments: The
<html> tag has some new attributes: xmlns, xml:lang, and
lang. In HTML, you only have to include the <html> tag to identify the
document as an HTML file, but XHTML requires that you use the xmlns
attribute to link your document to the W3C’s definition of XHTML,
which continues to evolve. You will learn more about this evolution and
how to prepare for it in Lesson 17, “Planning for the Future.” For now,
just remember to include the
<!DOCTYPE> tag and the full <html> tag
(shown in the following sample) in all your Web pages. Figure 2.3
demonstrates how the XHTML page, created previously, would appear in
the browser.
<!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”
xml:lang=”en” lang=”en”>
Caution This book uses the Transitional variation of
the
<!DOCTYPE> tag throughout. It’s a good habit to
get into, allowing you to conform to W3C rules, but
offering more flexibility that the Strict variation.
FIGURE 2.3 Notice that adding the XHTML declaration does not
affect your page’s appearance.
Caution The <!DOCTYPE> tag is the only tag that
appears in uppercase. All other HTML tags should be
lowercase as explained in the next section.

Get Sams Teach Yourself HTML in 10 Minutes, Fourth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.