CSS background-image property
The background-image
property sets the image background for an element. You can define the image's location with the url()
function, putting the address in the quotemarks inside parenthesis: background-image: url("space.png");
.
In the example above, we also added a gradient — a transition between purple and blue (we'll talk more about gradients in one of the next lessons). Adding gradient data type to your background-image
declaration will affect the background image.
There's also a shorthand property background
that allows you to set individual properties like position, size, repetition, and more in a single declaration.[1]