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 How to Make a Website Creating HTML Content Add Image Gallery Content

Shwetha Venkatesh
Shwetha Venkatesh
239 Points

I am not getting images when i use relative path with <img>

I am not getting images when i use relative path with <img>

Can you please post a snapshot of your workspace? You can see how to do that here: http://www.teamtreehouse.com/forum/workspace-snapshots

Shwetha Venkatesh
Shwetha Venkatesh
239 Points

The relative path i gave was wrong. I corrected it. Thank you

Excellent! :)

jason chan
jason chan
31,009 Points
<img src="/img/smiley.gif">

or

<img src="../img/smiley.gif">

i hope that helps. Try learning some command line and you'll see. The dot dot is up two directories back in that one is usually for css. the first one is for html. It's basically the location of the file.

Jason,

Your first <img> element does not have a relative path. If you include a / at the beginning of the file path, you are telling the browser to go back to the root directory of the server, not the path it is on currently. A relative path looks like this:

<!-- Goes to "img" folder in current directory i.e. this is a relative path -->
<img src="img/smiley.gif">

<!-- Goes to "img" folder in root directory i.e. this is an absolute path -->
<img src="/img/smiley.gif">

Your second <img> element is done correctly as that would go to the folder above the current path and go into the "img" folder for "smiley.gif".