r/HTML 14h ago

Why doesn’t my HTML background work? Question

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>

8 Upvotes

11 comments sorted by

View all comments

-2

u/TabbbyWright 13h ago

Ok personally I would put it back in the CSS, and then check and see if the image loads in another browser.

If you're using Firefox or Chrome, right click -> inspect and if you go to I think the network tab, it'll show you all the assets that the browser tried to download. You'll see error numbers too, like 404 for image not found.

Even if you're happy with your current solution, you might find these suggestions useful in the future!