Khamis, April 25

Chapter 1: Getting Started With HTML

Chapter 1: Getting Started With HTML

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 document, it would look like the following:
<!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 Chapter 4, "Adding Style." The Strict variation 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 Chapter 9,"Creating Frames."
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
    frameset.dtd">

You might have noticed one more change from the HTML required elements: 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. Below figure demonstrates how the XHTML page, created previously, would appear in the browser.
Click here to view a larger image.

Tiada ulasan:

Catat Ulasan