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

General Discussion

Trouble with img coding

Hi:

I'm stuck. I'm trying to add an image to the body of my page and the image won't appear. Here's how I have the code typed:

<img src="img/logo.gif" alt="Smells Like Bakin">

But when I refresh my browser, the pic doesn't appear. I'm assuming it has something to do with the file path I'm referencing. I saved the file here:

/Users/CarmelMikol/Documents/Team Tree House/websitewaters-island01-stage02/img

I did try referencing more of the file path, but I still couldn't make it appear.

Help?

[[ed.note:]] Added markdown to fix code formatting

10 Answers

I can't see your code!

The 2 most common mistakes when images are not showing up are a typo with the file names or using the wrong file path.

So triple check that you are using the exact name of the image files in your HTML, if that doesn't resolve the issue, check the file paths.

Here's a quick primer on file paths that should get you going.

Let us know how you are getting along with this here in this thread.

I'm not sure which course you're taking, but if you are really having trouble with this, try to pass it the entire address.

Example:

<img src="https://www.google.com/images/srpr/logo4w.png" alt="The Google Logo">

i had the same trouble but i figured that i don't really need to use the folder name. so instead of typing..

img src="img/logo.gif" alt="smells like bakin"

just type:

img src="logo.gif" alt="smells like bakin"

hopefully this will work.. Good luck

What is the file path of the HTML file that references the img src URI?

Thanks I'm trying a few of your suggestions. In the meantime:

Charles, here's the file path of the page I'm working on: file:///Users/CarmelMikol/Documents/Team%20Tree%20House/index.html

And here's the file path of the image I'm trying to link: /Users/CarmelMikol/Documents/Team Tree House/websitewaters-island01-stage02/img/logo.gif

I'm on the Stage - Building a Simple Website - Beginnger: Text Editors & HTML. I've seen the page respond to my coding a tab title, so I know the text editor is speaking to the browser properly. Just can't get the image to show. The instructor say to simply type src="img/logo.gif" but that hasn't worked for me

Any more ideas? Thanks

Also does it matter where you save your program files from the course on your computer? I put them in a specific folder when I downloaded the course program files. And now I"m trying to follow that path in my html coding, but it's not working. What am I missing?

Also does it matter where you save your program files from the course on your computer?

It does if, your directory structure is different than how Nick had his directories setup in the video.

In your case, your img directory isn't directory inside the folder that has your html file the Team Tree House directory, your img directory is nested inside the websitewaters-island01-stage02, you need to alter to your file path to account for this change.

Change:

<img src="img/logo.gif" alt="smells like bakin">

To This:

<img src="../img/logo.gif" alt="smells like bakin">

The .. refers to moving up one directory relative to where the html file is. To learn more about how this works, check out this quick primer on relative paths.

Well.... this is interesting. I moved the img file into the same level directory as my index.html file. Then I went to the html page in my browser, hit "inspect element" and edited the html coding from there( i just used src="img/logo.gif"), and the picture appeared!

Hm. I'm still not sure I know why it wasn't working. But I guess it had something to do with the place the file was saved on my hard drive.

Moving on now. Thanks for all the help!

@carmel -- 2 quick things.

  1. when I dev sites, I like to keep move everything into a brand new directory. Rather than keeping things in the download folders, just create a directory that looks like this:

/mysite |---/img | |----logo.gif | |---other-image.png | |---/css | |---style.css | |-index.html

This will keep you from getting confused and (hopefully) having to move up/down directory paths too much. (though @james has a good reference there for you)

  1. It may not show because of your Browser Cache. Depending on your settings, your browser will save a version of a website, so that it does not have to download the same images each time. (helps with faster browsing). -- try clearing your browser cache, or alternately, viewing the same file in another browser. (since you're using Chrome, check it in Safari or IE -- if the image shows, it's your browser cache)