CSS Background

CSS Background

CSS background properties are used to define the background effects of an element.
CSS properties used for background effects:

  • background-color
  • background-image
  • background-repeat
  • background-attachment
  • background-position

 

Background Color

The background-color property specifies the background color of an element.
The background color of a page is defined in the body selector:

Example


<html>
<head>
<style>
body
{
background-color:#b0c4de;
}
</style>
</head>

<body>

<h1>My CSS web page!</h1>
<p>Hello world! This is a W3Schools.com example.</p>

</body>
</html>

Background Image

The background-image property specifies an image to use as the background of an element.
By default, the image is repeated so it covers the entire element.
The background image for a page can be set like this:

Example

 <html>
<head>
<style>
body {background-image:url("paper.gif");}
</style>
</head>

<body>
<h1>Hello World!</h1>
</body>

</html>


0 comments:

Post a Comment