Thursday 4 May 2017

Set background color and background image in CSS for page

Set background color and background image in css for page:
In the CSS background-color property is used to set the background color for the web page

The background color of a page is set like this:


<html>
<head>
<title>
Set Background color in css for page
</title>
<style>                                                               //style tag is used to specified the css style
body {
    background-color: lightblue;                          // background color is set by lightblue
}
</style>
</head>
<body>

<h1>Hello World!</h1>

<p>This page has a light blue background color!</p>

</body>
</html>

Output or the Browser view of the above web page:

In this web page the background color is lightblue 


Set Background image: 
In CSS we use backround-image:url('path of the image/location of image\name of image .extension');

<html>
<head>
<title>
Set Background color in css for page
</title>
<style>                                                            
body {
    background-image:url('C:\Users\Public\Pictures\Sample Pictures\Desert.jpg');                        
}
</style>
</head>
<body>

<h1>Hello World!</h1>

<p>This page has a image on the background!</p>

</body>
</html>

Browser view of above web page:



No comments:

Post a Comment