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
Randhir Rana
4,754 PointsFirst Website Project
Hi I am setting up my first website and having trouble putting an image in my main header.
Here is my code /* .Main-Header { background-image: url('header.jpg'); } */
I know this is a relative file path error, but i can't seem to line up the proper file directory. I am using a mac and the file is placed inside a img/projectfolder/desktop.
Please Help Thanks!
2 Answers
Ted Sumner
Courses Plus Student 17,967 PointsYour image path is very strange. I would move the image into the project folder and set up a file tree that is more standard with the project folder, and the img folder inside the project folder.
Desktop is usually at the top of the tree. I suggest you carefully examine the path. It is probably desktop/projectfolder/img. If so, then your code path depends on where your css file is. If it is in a css folder, then the path is ../img/header.jpg
Jeff Lemay
14,268 PointsThis is assuming your stylesheet (where this code is) is located inside a css folder.
../img/projectfolder/desktop/header.jpg
So we go up one directory to get out of the css folder by using "../", then we go into the img folder, into projectfolder, into desktop, and there's our image.
Randhir Rana
4,754 PointsRandhir Rana
4,754 PointsHere is my code:
'''.Main-Header { background-image: url('header.jpg'); }
h1 {
}'''