How to Write CSS Style Sheets
- 1). Open a new file in a plain text editor, such as Notepad on Microsoft Windows.
- 2). Type the selector you want to style. The selector is the name of a tag used in your HTML document such as "p," "a" or "h1." Press the space bar, then type "{" to begin styling your selected tag. For our example, style the "<p>" tag by typing:
p { - 3). Press "Enter" to go to the next line, then enter a property. Properties include color, font-family and font-size. Type "color: blue;" to change the color of the text to blue. "Color" is the property and "blue" is the value. After every value, type a semicolon to indicate that it is the end of your style. Enter another style by typing "font-family: Tahoma;." Include as many properties as necessary for each style.
- 4). Type a "}" at the end of the style. Press "Enter" to go to a new line to begin a new style. The code for the sample paragraph style would be:
p {
color: blue;
font-family: Tahoma;
}
If you want to use the same style for two or more codes, such as the paragraph and h1, type it as follows:
p, h1 {
color: blue;
font-family: Tahoma;
}