Style Sheets: Linked
Linked Style Sheets allow the use of a main Style Sheet for all or any pages. The external Style Sheet file sets rules for all the pages that use it. Changing one detail in the Style Sheet file can change all those pages instantly, simplifying large site maintenance. This style is used with the <link> tag in the <head> of the page:
|
<html lang="en"><head>
<h1>Style Sheets</h1> </body></html> |
Now create a separate text file called stylsht.css (you can name it anything you want). All it contains is your definitions:
|
h1 {color:#66cc66; font-size:22px; font-style:italic; font-family:arial,sans-serif;} p { text-indent:1.5cm; background-color:cyan; font-family:times } |
Put this CSS file on the web server the same as you would an HTML file. When you then view the page, you'll see that the browser has followed the <link> tag and honored all of its Style Sheet rules for that page. You can link to the same Style Sheets file from an unlimited number of HTML documents. You can use relative or absolute URLs with the HREF attribute. These two files give the same web page content shown in the previous example.
[Updated: Sunday, November 18, 2007]
