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 trialPaul Rosenbeck
Courses Plus Student 1,089 Pointsadding an image
So here is my code, any ideas why it's not working?
<!-- img src="cupcake.jpg" alt="cupcake" / -->
I added the comment so it would appear in the forum... I tried it with an open ended tag and closed tag
8 Answers
James Conner
9,821 Pointssrc should also include the directory. They mention it is in the directory of "img" (a common practice) and as such should be listed as src="directory/file.extension" so if I had an image named "headerimage.jpg" in my img directory, it would be:
html <img src="img/headerimage.jpg" alt="headerimage"></img>
trying to not just give the direct answer to the code challenge away... sorry.
Paul Rosenbeck
Courses Plus Student 1,089 Pointswhere do I find the directory/filepath?
Mattia Gobbi
4,595 Points<img src="cupcake.jpg" alt="cupcake">
Is this the code you tried? It should work. If no image is showing the reason is because the file cupcake.jpg is not in the same folder as the HTML file.
Please refer to the answer of James, I didn't notice that the question was strictly related to a code challenge!
Paul Rosenbeck
Courses Plus Student 1,089 PointsWhere is it and how do I move it?
Paul Rosenbeck
Courses Plus Student 1,089 PointsBecause thats exactly what my code looks like. I am used to Textastic, an iPad editor. It makes thing much easier and way more user friendly
James Conner
9,821 Pointsthey mention that the image is inside the directory img so,
<img src="img/cupcake.jpg" alt="cupcake"></img>
Paul Rosenbeck
Courses Plus Student 1,089 PointsI'm on my way again, thanks for the help guys!
James Barnett
39,199 PointsSounds like you've got a file path issue with your images.
The way it works is that you have to put your images in the correct folder relative, to your HTML file.
Here's an example:
Does that help?
If not, you can read up about absolute vs relative paths
James Barnett
39,199 PointsJames Barnett
39,199 Points>
I added the comment so it would appear in the forumThe forum uses markdown to correctly format code, check out this thread on how to type code in the forum for some examples.