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

HTML How to Make a Website Styling Web Pages and Navigation Make a CSS Image Gallery

Soo Kim
Soo Kim
2,640 Points

I am typing in #gallery li { color: black;} when it tells me to change text color but it says it's wrong?

For the 4th question, I'm choose a color and background color of my choosing but nothing is working and the code isn't going through. I'm pretty sure the code is correct?

6 Answers

Chase Lee
Chase Lee
29,275 Points

Don't use black as the "color".

Soo Kim
Soo Kim
2,640 Points

it doesn't matter. any color i use doesn't work

Chase Lee
Chase Lee
29,275 Points

Hmm...Could you paste all of the code you're using so I can help you better?

Soo Kim
Soo Kim
2,640 Points

Thanks Chase! I passed it now. I had one last question from the quiz tho.

I'm trying to wrap my head around floats.

This code:

gallery li{

float: left; width: 45%; }

Why are we floating this to the left? Does it make any difference if I DON'T use a float property? Since the gallery images themselves are centered.

Chase Lee
Chase Lee
29,275 Points

Read this article to get an in-depth idea of what you floating does.

The basic idea of floating is that the page and text will "flow" together like in a newspaper. If it wasn't there, then the text could go through the image. I said "could" because this doesn't always happen for various reason (like other factors influencing it). But the float makes sure this doesn't happen.

To be honest, I'd have to check the code challenge again to see what's going on. But from what I understand, the reason it probably doesn't do anything is just because nothing needed to be changed at the moment. (You'll be doing this a lot in code.)

I hope that helps you.

Chase Lee
Chase Lee
29,275 Points

Okay, so I read your comment again. So to answer your question more specifically, the reason you float is to help merge images and text. It doesn't actually "center" the image.

You have to set the color AND the background add this too your #gallery

#gallery li {
color:black;
background:white
}
Chase Lee
Chase Lee
29,275 Points

That would be:

background-color: white;

Just a heads up, using black didn't work for me. So after you apply the changes, you should change the color to something like blue in order to pass.

there is no difference since background is a shortcut for

background-color
background-image
background-position
background-repeat
background-attachment
background-clip
background-origin
background-size

of course it is mostly used when you add more values to it

Chase Lee
Chase Lee
29,275 Points

Oh yes, sorry for the confusion. I just didn't know if the challenge would accept background as the correct answer.

So i just tested it and it seems that color:black; is not accepted for some reason strange

Chase Lee
Chase Lee
29,275 Points

Lol! Yeah, it's weird. ;)

Soo Kim
Soo Kim
2,640 Points

By the 4th question I have this code down:

gallery li{

float: left; width: 45%; margin: 0 2.5%; color: #000000; background: #ffffff; }

But it tells me "Bummer! It looks like one margin is correct, but others aren't. Be sure to set all gallery list items to 2.5%" I tried margin: 0 2.5% 0 2.5%;

What am I doing wrong?

Chase Lee
Chase Lee
29,275 Points

So you don't need to set the margin to 0 2.5% just 2.5%. Also, I ran your code, and if you want to pass, you need to change color to an actual color like blue.

Billy Bellchambers
Billy Bellchambers
21,689 Points

Maybe the code challenge will not accept black as this is the browser default. Even though the text appears colored in the preview as they have anchors attached? Therefore choosing black you haven't really changed the color?

Still a strange code challenge blip either way.

Soo Kim
Soo Kim
2,640 Points

Ah okay! Also had another question

I'm trying to wrap my head around floats.

This code:

gallery li{

float: left; width: 45%; }

Why are we floating this to the left? Does it make any difference if I DON'T use a float property? Since the gallery images themselves are centered.

this should work :DDD

gallery li {

float: left; width: 45%; margin: 2.5%; color: yellow; background: orange; }

btw it wont take white or black any other color tho