css background: ; code example

Example 1: javascript style background color

// change background color for specific id ..
function changebackground(){
	document.getElementById('id').style.backgroundColor = 'green' ; 
}
// change background color for whole body..
function changebackground(){
	document.body.style.backgroundColor = 'green';
}

Example 2: css last child

li:last-child {
    background-color: lime;
}

Example 3: html background image

<!-- Code by Scratchy -->
<!-- Twitter: @S_cratchy-->

<head>
  <style>
    body {
      background-image: url(https://wallup.net/wp-content/uploads/2019/09/110394-cats-grey-kittens-fluffy-fat-grass-animals-cat-kitten-baby-cute-748x468.jpg) 
    }
  </style>
  
  <body>
    You have set the background image!
    
    
    
  </body>

Example 4: how to add background in css

body {
 background-image: url("paper.gif");
 background-color: #cccccc;
}

Example 5: css change background color of page

/* Use the following code: */
html {background-color: #fefefe;} 
/* You can change the hexedecimal code to RGB, RGBA, name & more colors!*/

Example 6: background color using css

/* To apply color to background you have to use 'background-color' property and value of property is color name. */
html,body {
  background-color: blue;
}

Tags: