Prev Next

Background-image

Background-image property is used to set background image.

Sample code

<style type="text/css">
 Body {background-image:url('filename.jpg');}
</style> 

Complete Example

<!DOCTYPE html>
<html>
<head>
<style>
body {
  background-image: url("bg.jpg");
}
</style>
</head>
<body>

<h1>Enjoy Life!</h1>

<p>This page has an image background</p>

</body>
</html>

By default, the image is repeated so it covers entire element.

Leave a Comment