In this lesson you will learn how to create your first style sheet. They are the basic model of CSS to know and we will show what lines of code are needed to CSS in an HTML document.
Many of the properties specified in Cascading Style Sheets (CSS) are used in similar way to those of HTML. If you use HTML for layout purposes, you will probably recognize many codes. Let us consider a concrete example.
The basic syntax of CSS
Suppose we want a beautiful red color as the background for our web site. In HTML, we could have done the following: <body bgcolor=”#FF0000″>
With CSS, we reach the same result by: body (background-color: # FF0000;)
As you can see, the code in HTML and CSS is more or less identical. This example just shown you the basic CSS model.
Try it for yourself! Open Notepad (or the text editor of your choice) and create two files – an HTML document and a CSS file – with the following contents:
default.htm
<html>
<head>
<title> My Document </ title>
<link rel=”stylesheet” type=”text/css” href=”style.css” />
</ head>
<body>
<h1> My first stylesheet </ h1>
</ body>
</ html>
style.css
body (
background-color: # FF0000;
)
Now save both files in the same folder. Remember, save the files with correct extensions (”.Css” and “.Htm”). Open the default.htm in your browser and you will see that the page has a red background. Congratulations! You have just created your first stylesheet.

