How to go up a level in the src path of a URL in HTML?
Use ..
to indicate the parent directory:
background-image: url('../images/bg.png');
Use ../
:
background-image: url('../images/bg.png');
You can use that as often as you want, e.g. ../../images/
or even at different positions, e.g. ../images/../images/../images/
(same as ../images/
of course)
Here is all you need to know about relative file paths:
Starting with
/
returns to the root directory and starts thereStarting with
../
moves one directory backward and starts thereStarting with
../../
moves two directories backward and starts there (and so on...)To move forward, just start with the first sub directory and keep moving forward.
Click here for more details!