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

background-image: url('wontLoad.whyNot')

I am following the tutorial on creating the Smells Like Bakin' website. I am downloading the source files and typing everything out on my own machine trying to learn everything. But for some reason, the bg-texture.jpg WILL NOT load in the browser. I have tried reading other sites for help, but the things I have seen have all been very obvious mistakes that I haven't made (not to say that I know anything at all, I just checked and didn't happen to make those mistakes) It loaded one time when I was just playing around, but now it won't load and I don't know what the deal is. Any Help?

17 Answers

Is there an image named bg-texture.jpg in a folder named css?

Using codepen.io is much easier than playing this guessing game at what your code may or may not have written.

Can you provide your directory structure for your web site?

E.G.

Web (root)
- - smellsLikeBakin
- - | - - img
- - | - - | - - backgroundImage.jpg
- - | - - index.html

If you don't have a web server setup on localhost then you will have to use the full path like you did here

file:///Users/darint07/Documents/Web/smellsLikeBakin/img/backgroundImage.jpg

If no bg image then what do you get?

Have you tried a test of removing everything else but the background?
Any way you can show us your code please?

Guil Hernandez
STAFF
Guil Hernandez
Treehouse Teacher

Hi Darin,

Can you please post a code example? Also, make sure you're not using other background properties in your background-image declaration.

Whenever I can't get an image to load 9 times out of 10 it's an issue with the path.

Here's a quick primer of paths

I'd read the blog post I linked and then triple check my path & filename.

Remember that filenames are case sensative on Linux / OS X systems.

Here is the only css I have written. Everything works except the bg-image. I am new to all of this so, I apologize if there is a rule for posting code and I broke it.

body{ font-family: 'Nunito', sans-serif; color: #FAF3BC; background-image: url('css/bg-texture.jpg'); }

@Darin - 2 that will help us, help you ...

  • A link to the code challenge you are having issues with, and the step you are stuck on
  • Create a "working" example using something like codepen.io, to help us see the bigger picture.
Guil Hernandez
STAFF
Guil Hernandez
Treehouse Teacher

Darin,

Try adding "img/" after "css/" in your image path.

There is no image img folder in the css folder. I have moved the .jpg file to several different folders trying to get it to work, but for some reason, it's just not loading. I am thinking about starting from the very beginning HTML and all, just to get it to work.

Darin,

Try typing the exact location to the image in your browser.

If the image comes up copy the URL and paste it into your css.

Then view your test page and see if the image shows up.

If the image shows up then you can start trimming the URL in your CSS.

I'll get on that codpen.io thing soon, but I tried what Joseph said to do and it worked, but now if I try to shave any of the file path off at all, it won't work anymore. I am so confused. Maybe I should just leave it as it is.

Oh, and to clarify I an working through the Build a Simple Website tutorial. I downloaded the source files, and am working through it on my machine aside from the code Challenges. I don't seem to have any problems with them. Thanks for all the help guys... Maybe someday I will know a little something about web development.

@Darin,

Could you post the bit of CSS code related to the image you are trying to access?

body{ font-family: 'Nunito', sans-serif; color: #FAF3BC; background-image: url('file:///Users/darint07/Documents/Web/smellsLikeBakin/img/backgroundImage.jpg'); }

Darin,

Can you access that image from http://localhost/smellsLikeBakin/img/backgroundImage.jpg?

I'm assuming smellsLikeBakin is a folder in your Root directory for your HTDOCS.

No, I haven't set up a local host yet. I was just starting to get the hang of things and then I left for bootcamp and didn't touch a computer for 2 months so I am starting from the beginning all over again. But It's coming back quickly.(ish)

Try WampServer. You can get a working server going in just a couple minutes with minimal effort.

Note If you don't speak French, don't forget to click the "English" link at the top right of the page.