Using Stylesheets in XHTML

You can use stylesheets in several ways in XHTML. As we already saw in this chapter, you can use the <link> element to connect an external stylesheet to a document, like this:

<!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>
            Working With External Style Sheets
        </title>
        <link rel="stylesheet" href="style.css">
    </head>

    <body>
       <center>
           <h1>
               Working With External Style Sheets
           </h1>
           <p>
           This document is displayed using an external style sheet.
           </p>
       </center>
    </body>
</html>

This XHTML links the Web page to an external stylesheet named style.css, written in CSS (refer ...

Get Real World XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.