Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't set background image in css

I am trying to set my background image of the page via CSS using the following code, but no image shows up. The image will be tiled on the page and is only 10x10px big. Nonetheless, it still doesn't show up. Please can you tell me what I am doing wrong?

<body>
    <div id="background"></div>
</body>


#background {
background-image: url("img/background.png");
}
like image 405
max_ Avatar asked Sep 07 '25 16:09

max_


1 Answers

Is the image in linkToCssFolder/img/background.png? The image path is relative to your CSS file.

Also, does your #background div have content in it? If not, it will probably have the default 0px height, and not show any background.

like image 60
Nightfirecat Avatar answered Sep 10 '25 07:09

Nightfirecat