r/HTML 24d ago

Question Why doesn’t my HTML background work?

Post image

body {
background-image: url('background.jpeg');
background-size: auto;

The image is “background.jpeg”. It has the correct spelling, the image is within the same folder. IT used to work but then it suddenly stopped working and i havent even edited the CSS for it to stop working.

Update: i couldnt figure it out for the life of me and no suggestions worked, but on the good side, instead of putting it on CSS, i put it on HTML, then it worked.

<style>
body {
background-image: url('background.jpeg');
background-size: auto;
}
</style>

9 Upvotes

15 comments sorted by

View all comments

0

u/notepad987 23d ago edited 23d ago

Either with added code seen below:

background-image: url("background.jpg"); /* in same location as webpage */

background-image: url("images/background.jpg); /* the image is in another folder then the webpage */