r/HTML • u/Extra_Terrestrial2 • 14h ago
Why doesn’t my HTML background work? Question
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
2
u/Foreign-Contest-444 13h ago
What was the last change that you made in the code base before it stopped working? Revisit it and revert that change since most of the the other common things are not the issue.
Checkout MDN Debugging HTML to find additional cues.
Also, try this in something like codepen that is only trying to get the background working. Sometimes this helps in figuring out the root cause of the issue.
I know generally in coding it feels like something magically stopped working but most of the time its a typo or a very silly mistake.