Linking a style sheet to a web page

An external stylesheet is linked to a web page using the <link> element in XHTML. A wb page can have any number of style sheets linked to it. The styles will accumulate and conflicting style are resoved on the basis that the last style in is the one which takes precedence.

The following code shows the position and syntax for linking an external style sheet called mystyles.css which resides in the same directory/folder as the webpage.

...
<html xmlns: ... lang="en">
  <head>
    <title>Scotty's Home Page</title>
    <link rel="stylesheet" type="text/css" href="mystyles.css" />
  </head>
  <body>
  ...

Note that the value of the href attribute of the link element can be any valid URL. i.e you can link to a style sheet on another server, or anywhere within your own web server's file space. However, it is considered bad practice to link your web page to a style sheet on someone else's web site, and could be construed as a breach of copyright as you would effectively be using the design directly from that site.

Valid XHTML 1.0! | Valid CSS! | WCAG Approved AA
Page design by: John P Scott - Hosting with: Netcetera