Page 148 - Computer Genius Class 07
P. 148
ou need to gi e complete dri e path o the stylesheet i the file is sa ed at any other location. et
us create a e page using the e ternal style sheet. The first step is to create stylesheet file. Open
the Notepad and type the following code:
body{background-color:green; color:white;}
o sa e the file ith the name style.css at any location again open a ne notepad indo and
type the following code:
<!DOCTYPE html>
<html>
<head>
<title> Using External Stylesheet</title>
<link rel=”stylesheet” type=”text/css” href=”style.css”>
</head>
<body>
Text with white colour and background colour is green
</body>
</html>
When you view the preceding web page in browser, you will get the following output:
You can also use the 6 digits hexadecimal code in place of colour name. For example, the hexadecimal
code #000000 represents the black colour and #FFFFFF represents the white colour.
For example:
body{background-color: #000000;}
You can also set an image as background of a web page by using the background-image property of
CSS in the following manner:
body{background-image:url(“background.jpg”);}
Cascading Style Sheets (CSS) is a convenient method of styling the elements of a webpage. It
controls various elements like the colour, font, text size, etc. within a single page or the entire
website. CSS can also be used to change the look of any webpage elements such as paragraphs, lists,
backgrounds, etc.
146 Computer Genius-VII

