02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Calling images in Parent Folder

Relative Paths: We don't mean how you can get to your ants house... Actually its exactly what we mean. Paths are paths in a computer or in real life. your relationship with your ant is much better I bet then your relationship with someone you don't know.

Just like working with images inside of the same folder there is a way to approach images that are not in the same folder but are in a folder or two above the current folder you are in. In this video we will demonstrate that and see how to update our HTML accordingly.

Video Transcript

00:00I want to talk about another couple of stuff.
00:03One thing is - what if our file was in a completely different folder?
00:08What if our file was all the way on the bottom here? What if a 'cheap thrill' file wasn't in the same folder
00:14Maybe it was in a folder back here? How would we get to that file ?
00:19The way we would get to it is very simple also,
00:21you just have to memorize this stuff and get used to them
00:23because you just need them when you're programming.
00:27In your editor, all you would do is - in the folder itself,
00:31instead of saying 'imgs' folder you're going to say 'go back one folder'
00:35to say to the browser: 'go back one folder ' is basically saying two dots
00:39When you saying '..' you're saying 'go back one folder'
00:42you want to go back two folders?
00:442 dots again. So in our case we're going to go back one folder and we're going to find a cheap thrill,
00:50so if I click on save again and we go into our browser and click on refresh,
00:54it should still find our file. It still finds our image and still everything is fine with it.
01:00Next thing I want to talk about is again, talking about file structures,
01:03What if the whole 'imgs' folder was in a different folder?
01:07and our image was right inside of there,
01:09okay? so now we have our html here, but one folder back, inside of the 'imgs' folder is our file
01:18Let me put you on the spot. -what do you think we should do to get there?
01:22-umm that '../imgs'
01:25- dot, dot, slash, imgs Exactly
01:28and then I click on save and if I go into our application again and we click on refresh again,
01:33We'll see that our image is still loading without any problem,
01:39These are all the things you need to know about how to find files and how to link them together in HTML
01:44All we said so far is called relative pathing,
01:50Relative pathing is quite simple. It's basically go back one folder, go two folders back,
01:55go folder inside, and you're literally step rating the folder with the slash
01:59So every time it's just a slash until you find the folder where your file is located out.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!