CSS Background Shorthand

CSS Background Shorthand


Background Shorthand
Background shorthand is used to reduce the code by writing all the background properties in a single property 
Note -
We recommend using shorthand property when you are well familiar with using all the background properties separately.
 
Note - The order of the values does not matter and every value is optional 
Syntax  - 
The syntax of the background shorthand declaration is - 
Writing all the background properties continuously and put a white space after every property to separate.
background: [] [] []/[]
[] [] [] []
[]; 
Now we will see Example - 
Here CSS  - 

body {
  background-color: #808080;  background-image:url("krshnaimage.png");

  background-position: left top;
  background-repeat: no-repeat;
}

Example-Now we can reduce this code, or shorthand this code as shown down below - 
Output -