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

CSS CSS Foundations Backgrounds and Borders Background Properties

Sam Deighton II
Sam Deighton II
24,466 Points

Trouble with Challenge Task 2. Please help.

Deep Dive: CSS Foundations: Stage 7: Backgrounds and Borders

Question:Next, add the image 'mike.png' located inside the 'img' folder to the background. We only want Mike to appear once, so follow it with a property and value that will not repeat the image.

my code:

.box {
  background-color:#387ABC;
  background-image: url('../img/mike.png');
  background-repeat: no-repeat;
    }

When i try to preview just the background image without repeat nothing shows up either.

3 Answers

Hi Sam,

When you add "../" before a file name, it moves you up one directory. You don't need to do that for this challenge because the html file is in the same directory as the img folder. So it should just be url('img/mike.png'); So it would look like this:

.box { 
background-color:#387ABC; 
background-image: url('img/mike.png'); 
background-repeat: no-repeat; } 
Sam Deighton II
Sam Deighton II
24,466 Points

I tried that and it worked! The other tracks I have done have had the css and img files in different directories, figured it would be consistent, guess not.

Thank you, Jennifer!

Kevin Tanner
Kevin Tanner
3,385 Points

I believe you do not need the ../ in front of img/mike.png because the image folder is in the current folder. The ../ is saying to go back one folder and look for the img folder.