Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML HTML Basics Images, Text and Links Captioning Images

At the beginning of this video, teacher wanted us to add vr-user.jpg in article.html

Can I just use this code to do it? <img src="img/vr-user.jpg">

Is it not that we need to group the images in one folder so we can easily access or link them to our webpage, which we did by placing the vr-user photo in the img folder?

Why do we need to type the " ../../ " for?

Sorry I am just confused. It's getting a lil tricky to follow now.

3 Answers

Well as Guil said in the video,he said that you need two to go to the roots of the project and then to reference it you add the img/vr-user.jpg path

Thank you, what did he actually mean by "and then to reference it"? Sorry English is not my first language. Is there another way to explain his instruction of ("and then to reference it") ?

He said in the video " So to display the image we need to reference a file in the image directory from inside the articles in 2017 sub folders. So we need to move out of the 2017 and articles subfolder.Back up to the root, and then back down inside the img folder."

My question is, if we wanted the image to show in articles.html, what is the reason of moving out of 2017 and articles subfolder, then back up to the root, then back down inside the img folder? What is the logic of doing it? Why can't we just insert the code <img src="img/vr-user.jpg"> to the article.html so the image will show?

Kieran Barker
Kieran Barker
15,028 Points

If you don’t add the ../, then the browser will look for a folder called img inside the current directory. But the folder isn’t inside the current directory.

Thank you! I did not realize there was no image folder in the file tree after all. Vr-user.jpg. is not inside an image folder. So is the code <img src="articles/articles.html/vr-user.jpg"> incorrect? Will this code let them access or display the vr-user photo on the website? Or is it wrong file path?

Oops, my bad. I just reviewed the video. I'm seeing the image folder, and the vr-user.jpg is inside it. Still confused. I'll try to keep grasping the concept so I figure this out

KAMRAN IMRANLI
KAMRAN IMRANLI
4,107 Points

You need to add "../../img/vr-user.jpg", because the file to which you want to add image (vr-user.jpg) is located in a folder which is located in a subfolder of the main root folder. So directory to the file, to which you want to add the image is "rootfolder/articles/2017/article.html". Thus, you want to include all the path in your directory of the image, that you want to add (because it is located in another subfolder of the root folder).

Hope it helps.