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 Styling Web Pages and Navigation Make a CSS Image Gallery

How do I open a folder for the images? how do I reference my images in my code?

<a href="index.html/Trees.jpg"> <p>Mixed forest.</p> </a>

css/main.css
a {
  text-decoration: none;
}

#wrapper {
  max-width: 940px;
  margin: 0 auto;
}

#logo {
  text-align: center;
  margin: 0;
}

h1, h2 {
  color: #fff;
}

nav a {
  color: #fff;
}

nav a:hover {
  color: #32673f;
}

h1 {
  font-family: Changa One, sans-serif;
  font-size: 1.75em;
  font-weight: normal;
}

1 Answer

Rasbin Rijal
PLUS
Rasbin Rijal
Courses Plus Student 10,864 Points

Hello Susan,

Hi Susan, Suppose your image file named image1.jpg is in the folder named img. Now, if this img folder is in same hierarchy as index.html file, you can reference your image like this :

<img src="img/image1.jpg">

It is a good practice to keep the folder (where images are located) in the same hierarchy as index.html file.

If your image1.jpg is in the same hierarchy as index.html file, you can directly reference to image file. You can also keep information about the image in the alt attribute, specify the height and width of the image inside the img tag.

<img src="image1.jpg" alt="Smiley face" height="42" width="42">

Hope this helps. Feel free to ask if you are not clear.

Happy Learning :)