Making Cascade Style Sheet
Open a text editing program. For example "Notepad" for Windows users, or "TextEdit" for Mac. For creating external CSS file you can use any plain text editor or special programs designed to edit CSS. There are many such programs, you can find commercial or free one.
Add the following code into your new blank text document:
CSS Code:
/* First CSS File Creation */ body { background-color: gray; } p { color: white; font-size:22px; } h1 { color: silver; }
Name your document as "test" and save as a CSS ( .css ) Now you have CSS file "test.css"
For using external CSS file, each page must link to the style sheet using the <link> tag.
In the source code of the page between the <head></head> tags add the following line:
<link rel="stylesheet" type="text/css" href="stylefile.css" />
In our example:
<link rel="stylesheet" type="text/css" href="test.css" />
Example of HTML file:
<html> <head> <link rel="stylesheet" type="text/css" href="test.css" /> <body> <h1> This is Header </h1> <p> This is paragraph </p> </body> </html>
Result:
This is Header
This is paragraph
Previous page: CSS Types
Next page: CSS Styling