CSE 154 Examples

Background Image Property

We can set a background as an image on any DOM element using the Background image CSS property. The Background image property takes in a URL (read file location) to an image that we want to set as the background. The URL can either be a local URL to an image location or an absolute URL to an image on the web. Remember that whenever you use an image from the web, cite it as needed either as a comment on the CSS or on the website directly.

Description

The Background image property helps us set the background-image on elements. The background image can either be set to a url of a local file or the absolute location to an image online.

Syntax :

              
                  element {
                    background-image: url('location_to_img')
                  }

                  p {
                    background-image: url("www.pixel.com/cool-images/coolest.jpg");
                  }
              
            

HTML :

CSS :

Live Preview :