<?xml version="1.0" encoding="utf-8"?>

CSS background-image property

CSS background-image property Bad Practice
CSS background-image property Best Practice

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]

Improve your UX & Product skills with interactive courses that actually work