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 trialSkyler Moon
12,670 PointsI was wondering what I was doing wrong here is my code, header { background-image: url("img_webtexture.jpg");
my goal was to add a image to use as the background for my header in css
2 Answers
Aurelio Decock
14,607 PointsHave you checked the path to your image? the link you are reffering to at the moment is a link in the root map. if you placed your image in a folder named "images" be sure to add it to the path like this:
background-image: url("images/img_webtexture.jpg");
Skyler Moon
12,670 Pointsok so I get what your saying and fixed it to but it still won't work do I have to add anything to the html my new css is header { background-image: url("img/web-texture.jpg"); and im clueless what is wrong
Aurelio Decock
14,607 Pointsdon't forget your closing bracket and check for any typo's
Aurelio Decock
14,607 PointsAlso, is there any content yet in the header? otherwise the header will not show since you didn't declare a width and a hight to it. make sure to add those aswell
Skyler Moon
12,670 PointsI have the closing bracket but I have a border-color element set to black but thats it
Aurelio Decock
14,607 PointsDefine your width and hight and width, it should be working this way
Skyler Moon
12,670 Pointsso I may sound stupid asking this but how would I go about judging the hieght and width and what unites would I use
Skyler Moon
12,670 PointsSkyler Moon
12,670 Pointsthe actual image name is "web texture.jpg" and the folder its in is named "img" so how would that be set up
Aurelio Decock
14,607 PointsAurelio Decock
14,607 PointsWell if you take a closer look at my code before it says:
background-image -> wich is the CSS you want to do. url -> this is where the link comes in between (" ").
Then it is followed by the map name / name of the image . extension.
I'll give you one more example but i'll leave it to you for your own css so you'll learn more.
if i have an image in the folder images, named profile-picture.jpg. the code will be:
note: if your css is in another folder, be sure to go back into the root folder by placing double dots in front of your url followed by a slash. like this: