Hello Everyone,
Trying to get my table for the Build Your Own Cheatsheet project
Ive built the table and met most of the criteria, but trying to give the page a little more pizzaz. In general a reoccuring problem I keep running into when working in VSC is I cant get the relative path to link.
Im trying to put a background-image in, but no matter what way I try to enter the relative path, I cant get a background image to show up. Up to this point, this is the most reoccurring problem I keep having that I cant resolve.
The background image Im trying to select is located in “HTML and CSS Cheatsheet\background.jpg”.
Anyone know what Im doing wrong? Ive visited several simular topics but cannot seem to workout a solution.
Any help would be most appreciated.
Thanks.
Hey,
If the image is in the same folder as thr css file, then do url("./background.jpg")
Juat remember the path is relative to the CSS file.
The file wasnt in the same folder as the css file, but for the sake of trying to get it to work per your instructions I moved the file there. Still not working.
Ah, now that I’m on desktop I can see your folders.
If index.css is here: /resources/css/index.css
And background.jpg is here: /resources/images/background.jpg
Then you need to do this: url("../images/background.jpg")
Put the image back in the images folder and give that a try.
Im still not getting it working. Are there conditons that must be met for it to link to the image in css besides the background-image property itself?

Thanks.
Could you please host it on Github so we can see the full file structure and code?
Ah, I see. if you change url("../images/background.jpg");
to url("./images/background.jpg");
then it will work.
../
goes back one folder. ./
refers to a file in the same folder. so ./images/background.jpg
refers to an image in a subfolder of the current directory.
Awesome. Thank you so much.
This seemed to do the trick.
Thanks so much for your assistance and time.
1 Like