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

Hannah Dowsett
953 PointsHow can I get images to work in my html?
I just finished watching and working through the "Images and Lists" section of "Text Editors and HTML"
I have opened a new document in a text editor and typed in all the code. When I go to my web browser, the list appears correctly, but there is no image? Just a box where it should be? How can I link it to an image on my computer?
Any insight into this would be much appreciated, as I'm pretty new to all this.
Thanks! Hannah
9 Answers

James Barnett
39,199 PointsHannah - 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.

Hannah Dowsett
953 PointsThanks @James Barnett... It still doesn't work though. :-/ I don't really get it. How do I find the file path to use? (Should I write everying ie: C:\Users\Hannah\My Pictures\etc, etc... ?)

Hannah Dowsett
953 PointsOh, don't worry about my other question... because IT WORKED!!!! yes! :D Turns out, I was writing <img src="img\C:\etc,etc.... I apparently needed to take out the img part of the flie location... haha :) No wonder it wasn't recognising the photo location! Thanks for your help :D

Kevin Korte
28,149 PointsYou are going to give yourself a lot of frustration down the road if you source your images using absoute image paths on your computer like you have shown.
<img src="\C:\Users\....etc">
Your image links will break when you move your website files from your computer, to your host computer. There are some pretty cool and flexible ways to code image sources that are shown in the advance PHP sections when you get there, but until that time, you should use relative links.
On your local computer with a testing server, your root folder is likely called htdocs. This will be the same or very similar on most web servers. If your images live in a folder called img inside of the root folder, your relative link would look like
<img src= "img/my_image.jpg">.
With a relative link, when you move your website from your local root folder to a web servers root folder, all of your links and images should still work.
The way you are coding it now, it will not.
I'm in no way pro, but I've built a few simple sites and have certainly taken my lumps and bruises, basically coding myself into corner that required a lot of work to fix broken things, like images and links.
Hopefully I didn't confuse you more!

Hannah Dowsett
953 PointsOk... thanks Kevin Korte. But, that doesn't really make sense?? How do I make a folder called img without using a "C Drive" root? Also, what is htdocs? But thanks for the tip.... when I figure out what you meant, I'm sure it will make sense... I hope :)

Kevin Korte
28,149 PointsMy apologizes Hannah, I assumed you where using a localhost server, but I assume you are just pointing your web browsers URL to your file located on your computer, in which case my suggestion will not work.
If you plan to do very much web development, I'd highly recommend downloading and installing a free local server for your computer.
My work computer is a Windows, and I have installed on it Xampp. On my personal computer it is a Mac so I have installed on it Mamp.
Both work and come with essentially the same things. One big part of the bundle of programs is it sets up a local apache server, which simulates a live web server.
So on my Windows work computer, I have Xampp installed on my C: drive. Inside of the Xampp folder is a collection of folders, one being called htdocs. The apache server installed with Xampp will use the htdocs folder as the root folder. So if you put your index.html file in the htdocs folder, make sure the apache web server is running, and type into your URL bar on your web browser "localhost" your web browser should show your web page as if it was live, but only your computer can view it. From there, you can build your site using relative links.
Than, when you go to move your files from your computer to a live web server, if you transfer your entire folder and file structure from you computers htdocs folder to your web server's httpdocs folder, all of you images, links, etc should still work perfectly.
If your computer is a mac, I'd use MAMP. I do personally. MAMP also uses an htdocs folder, works exactly the same.
That may sound really confusing, it was for me when I started figuring all of that out, but it's worth understanding what I just tried to explain.
Now I couldn't image trying to build a website without Xampp or MAMP installed on my computer.

Hannah Dowsett
953 PointsOk... Sounds complicated :-/ I'll have to research it a bit... Do you know whether treehouse has a video on this topic? Kevin Korte Thanks for bringing this to my attention though... better for me to learn this stuff now, then to have frustrating problems with my web designs later down the track, I reckon :)

James Barnett
39,199 Points
Hannah Dowsett
953 PointsOk, thank you James Barnett :)