Next / Previous / Contents / TCC Help System / NM Tech homepage

2. Connecting your page to a style sheet

CSS defines a style sheet language that you write to describe the presentation you want. This language can be included in your page or stored in a separate file.

Assuming that you want all your pages to share the same basic style, the best approach is to use a text editor to write your CSS rules in a separate text file and then use a special <link> tag on each of your pages to point to that file.

For example, you could write your CSS rules into a file called mystyle.css and then place this tag somewhere inside the head element of each of your HTML pages:

<link rel='stylesheet' href='mystyle.css' type='text/css'>

The href='…' attribute will accept any URI, just like the href attribute of the HTML <a> tag.

Here's a small, complete Web page with a stylesheet link:

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Small example page</title>
    <link rel="stylesheet" href="mystyle.css" type="text/css">
  </head>
  <body>
    <h1>Title</h1>
    <p>
      Sample paragraph.
    </p>
  </body>
</html>