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 trialRonald Jackson
9,229 PointsDon't understand why I got Challenge task 4 correct!
Challenge task 4 of 5 asks: "With the anchor elements inside the contact-info list still selected, set the background size to 20 pixels square. Then set the left padding to 30 pixels, with all other padding at 0."
My CSS was as follows: background-size: 20px 20px;
My answer is correct, but I don't understand why. At first, I answered "20px." When I discovered that my initial answer was incorrect, I guessed the correct answer. I don't understand why repeating 20px is the correct answer. It works but I don't really know why it works. Receiving positive feedback is great when one completes a challenge, but my goal is to really understand what I'm doing.
Can someone please explain why "background-size 20px 20px" is correct.
3 Answers
Colton Fitzgerald
15,815 PointsIt's great you asked! Here's the reason why two is correct.
The first "20px" is for the width of your background's size and the second "20px" is for the height. Here's an example:
In the statement "background-size: 40px 20px;" It will be 40px wide and 20px tall.
idan ben yair
10,288 PointsYup Colton is on point.
Check out this info as well:
http://www.w3.org/TR/css3-background/#the-background-size
w3 website is very helpful when you are trying to understand things of this nature.
Ronald Jackson
9,229 PointsThanks for the link to an additional resource. I will check it out!
idan ben yair
10,288 PointsNo problem Ronald anytime! :)
Ronald Jackson
9,229 PointsRonald Jackson
9,229 PointsWow! That was simple ... THANK YOU ... I got it now. I guessed the answer based on the "square" in the question, but I wasn't confident. I got it now.