CSS Background

Back Ground Color

How to set the background color for an element.

<head>

<style type="text/css"> body {background-color: green} h1 {background-color:#CCFFFF} h2 {background-color: transparent} p {background-color: rgb(210,0,234)} </style>

</head>

  

<body>

<h1>This is header 1</h1> <h2>This is header2</h2> <p>This is a paragraph</p>

</body> </html>

How to set image as the background.

<html> <head>

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

</head>

<body> </body>

</html>

Example
How to repeat a background image only vertically.

<html> <head>

<style type="text/css"> body { background-image: url('backimage_sun.jpg'); background-repeat: repeat-y } </style>

</head>

<body> </body> </html>

 
How to repeat a background image only horizontally.

<html> <head>

<style type="text/css"> body { background-image: url('backimage_sun.jpg'); background-repeat: repeat-x } </style>

</head>

<body> </body> </html>

Post Comment
Login to post comments