Relative parth is not working for background-image while it is correct

my relative path is not working for background image in my project while i have to put right path

@manojsoni007, welcome to the forums!

From your screenshot, it actually looks like that relative path is not correct. Remember, the path is relative to the file you are typing in. It looks like your CSS file is in a folder called css, whose parent folder is resource. You are trying to access an image that is not in the same folder, but rather in the image folder, which is also contained in the resource parent folder.

In order to access something in the image folder from a file in the css folder, your path first has to navigate back to the resource parent folder.

To do this, just use ../

If you can’t figure it out, click below to see the proper path:

Click here for code


1 Like

No problem. You might want to brush up on absolute vs. relative paths to avoid this problem in the future, as it’s a very simple fix once you wrap your head around the concepts.

Happy coding!

1 Like

it’s working properly using your solution. but i don’t understand what was the problem. what mistake i had done in relative path and where i have to put all my media file?

/resource/image/pattern.jpeg looks for a directory named resource inside of the directory your css file is in, rather than looking for a parent directory named resource.

I’m sure Codecademy covers this in either the html or css course, but you can also just Google “absolute vs. relative path” and find plenty of articles and videos that go into more depth.