How to Make a CSS File
External CSS files are used when you want to add the same style to multiple pages. They are also used if you have many different style definitions to declare. The CSS file is created as a plain-text document with the .css file extension. The CSS document is uploaded to the same directory as the HTML files on your Web server. The HTML "<link>" tag is used to reference the CSS file so that you can apply the styles to your webpage.
Instructions
-
-
1
Open a blank document in any text editor, such as Notepad.
-
2
Type the following to make the background color of the webpage blue:
body {background-color: blue;}
-
-
3
Type this line to specify that you want any "h1" element's font to be bold and gray:
h1 {font-weight: bold;
color: gray;
}
-
4
Type the following to create a class that can be used to center text:
.center {text-align: center;}
-
5
Add any other CSS styles that you want to use on your webpage.
-
6
Save the file with the ".css" file extension -- for example, my_style.css.
-
7
Add these lines to your HTML document to use the styles on your webpage:
<head>
<link rel="stylesheet" type="text/css" href="my_style.css" />
</head>
-
1