Skip to Main Content or Page Contents
CSS External Style Sheet Introduction
Where to place a CSS External Style Sheet Code
How to Link to an External Style Sheet
Writing the CSS External Style Sheet Code
The best & most popular method for Multi page sites that have the same styling
The very big advantage of using External Style Sheet(s) is that the css rules are placed into a separate file, and these rules will apply to every page that you refer to this file.
The reference is made in the HEAD section, normally just before the end </head> tag and follows the following format:
<LINK rel="STYLESHEET" href="path/name-of-file.css">
If you are going to save your file my.css into the same directory that contains your web pages you do not have to worry about the path/ portion.
If the file is in a different directory, then you would have to use either
Style Rules are made up from a Selector and Declaration(s) as follows
Selector {Property 1: value; Property 2: value; and so on;}
To make it easier to read, you can write the rules as follows:
Selector { Property 1: value ; Property 2: value ; and so on; }
This may seem confusing but the example in the next step should help to make it clear.
Using Notepad or a Style sheet editor, enter the following. You can copy and paste this code if you prefer.
Pay particular attention to the puntuation i.e. : ; , - { } make sure they are used in the correct place. A mistake in the puntuation is hard to spot and can lead to results that are difficult to understand.
h1 { font-family: Arial, helvetica, sans-serif; font-size: 14px; font-weight: bold; color: red; text-align: center; background-color: blue; }
This site is hosted on Hostgator