htmlcssimagebackgrounddocument-body

How can i set a background image with CSS?


I just started to learn HTML and CSS and i'd like to know how to set a background image covering the whole body element using CSS?

I've tried this way, searched an image on Google, copied and pasted its external link into CSS code and refreshed the page, but it doesn't seem working:

body {
 padding: 10px;
 background-image: src="https://backgroundcheckall.com/wp-content/uploads/2017/12/technology-background-image-11.jpg"; }

Do you know any better methods? Thank you!


Solution

  • You are following the wrong format, if you want to add the background-image, the correct format is

    background-image: url('link to image');
    

    In your code

    body {
     padding: 10px;
     background-image: url("https://backgroundcheckall.com/wp-content/uploads/2017/12/technology-background-image-11.jpg"); 
    }