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
Kevin Lewis
Front End Web Development Techdegree Student 9,667 PointsHave been trying for hours to add a background to my header but I just can't seem to get it.
header { text-align: center; background-image: url(img src='../images/montserrat.jpg'); no-repeat top center ; background-size: cover; overflow: hidden; padding-top: 60px; }
Dave StSomeWhere
19,870 PointsThere are other syntax errors in your original rule.
What does your statement looks like now? Did you also fix the missing properties forno-repeat top center. Maybe try thebackgroundshorthand withbackground: no-repeat center url('../images/montserrat.jpg');`
4 Answers
Dave StSomeWhere
19,870 PointsAre you sure that img and src = are valid within the url()? url(img src='../images/montserrat.jpg');
Max Senden
23,177 PointsHi Kevin,
When I copy paste your code in codepen it renders just fine. So it's like Dave says: your pathing is wrong. Also make sure to check if your image contains any capitals and whether or not the filetype (.jpg, .png, .gif...) is correct.
Good luck, Max
Kevin Lewis
Front End Web Development Techdegree Student 9,667 PointsDon't really understand. It is the same path that I used for the profile image and it's working fine. Still not sure what I'm missing in order to make the image appear in the background.
Kevin Lewis
Front End Web Development Techdegree Student 9,667 PointsI have and I’m still getting the same result
Kevin Lewis
Front End Web Development Techdegree Student 9,667 PointsWrote it exactly how you have it and the image is still not showing up.
Dave StSomeWhere
19,870 PointsDave StSomeWhere
19,870 PointsHave you tried removing the invalid stuff
img src=from your url property?(from MDN) - The <url> data type is specified using the url() functional notation. It may be written without quotes, or surrounded by single or double quotes. Relative URLs are allowed, and are relative to the URL of the stylesheet (not to the URL of the web page).
You don't want to copy your whole
imgelement, just the path portion.Please try
url('../images/montserrat.jpg')