Assignment1/*.html filesAssignment1/style/cssfile.cssAssignment1/images/images.pngHow do i call an image from Assignment1/style/cssfile.css to Assignment1/images/images.png file?
I can`t do it like the html files as i could just forward the folders to go through. I am trying to do:
.top {background-image: url("Assignment1/images/deco1400.png");}
from the css file to no avail.
How can I reference my image files from my CSS that are in different directories.
try
background-image: url("../images/deco1400.png");
Your tree structure is like
Assignment1
style
style.css <- you are here
images
img1.png
so either you need to go 1 level up (..) and then enter images OR you need to give absolute path /images/img1.png (note / at the beginning). Both should work, assuming Assignment is your root directory
UPDATE: you might be interested in reading about relative and absolute paths.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With