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 Find Image Path?

Hi all,

Having trouble with the challenge question:"Assuming an 'img' directory with an image 'cupcake.jpg', add the image to the body of the document"

My code is below. Unfortunately, the image doesn't show up and I am told to check the image path. I had trouble getting the image to show up during the exercise, until I copied the file location from codepen. What am I doing wrong, and how does one find the image path?

<!DOCTYPE HTML>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Smells Like Bakin' Cupcake Company</title>
  </head>

  <body>
    <img src="img/cupcake.jpeg" alt="Smells Like Bakin">

  </body>
</html>

Your code should look like this <img src="ing/cupcake.jpg" alt="Smells Like Bakin"> the problem is in the file name it is jpg not jpeg.

Hi Yordan,

Yep I realized that later. Whoops! Thanks for the heads up!

2 Answers

The code you pasted won't do anything.

If its css try:

body{ background: url(../img/cupcake.jpg); }

The image path is the same you would see in windows. c:/img/cupcake.jpg. If your image is in a subfolder make sure you add "../" before the img folder so it backs out a level. This would be if img is a folder and css is in a folder.

Thanks Matthew! I realized my error, and this helps!

Mathew is correct.