Nikita Manahov Nikita Manahov - 7 months ago 7
HTML Question

How do I add a background to my html document?

I have attempted adding a sky background to my website's stylesheet, but nothing really happened.

body {
background: "sky-08.jpg";
}


When I previewed the page, the background was white, like when I just started making my page.

Answer

It should be: background-image: url("sky-08.jpg");

This also assumes that the image file is in the same location as the CSS file (Or HTML file if it is inline)

If the image is located under an images folder in the root directory: background-image: url("/images/sky-08.jpg");

Comments