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

Add a margin of 2.5% help

Hey I'm having a hard time passing this challenge, I've read 3 different posts surrounding this and changed the code exactly, to no prevail.

Am I missing something or is this just bugged?

Mark Buskbjerg
Mark Buskbjerg
20,986 Points

I have the exact same experience. I've tried several solutions. Either I'm missing something in the question, or there is a bug.

9 Answers

Aaron HARPT
Aaron HARPT
19,845 Points

I passed with this code:

gallery li {

margin: 2.5%; color: black; background: white; }

Mark Buskbjerg
Mark Buskbjerg
20,986 Points

This doesn't work for me

Aaron HARPT
Aaron HARPT
19,845 Points

Actually, #gallery li.

This is what I have but it still won't work...

#gallery li { float: left; width: 45%; margin: 2.5; color: black; background-color: grey; }

you need to add a percent sign to the margin: (e.g. margin: 2.5%;)

Jesus Menera
Jesus Menera
17,304 Points

Hi Armando, You are missing the percentage sign % like this:

margin: 2.5%;

Sorry I missed it this time because I did the exercise from start to finish 6 times now.. it doesn't work again here is the updated code:

#gallery li {
  float: left;
  width: 45%;
  margin: 2.5%;
  color: black;
  background-color: grey;
}
Jesus Menera
Jesus Menera
17,304 Points

It looks fine to me. Once I encounter a bug doing a css exercise. To fix it. I just put the code in a single line and I put the margin on the first line like this. #gallery li { margin: 2.5%; float: left; width: 45%; color: black; background-color: grey; }

Try it. You may get lucky. Your current code looks fine.

Nope that did not work lol...

Jesus Menera
Jesus Menera
17,304 Points

The only thing I can think is maybe they are asking your for a class instead of an id. An id is like this: #gallery and a class is with a period at the beginning like this: .gallery

.gallery li { margin: 2.5%; float: left; width: 45%; color: black; background-color: grey; }

but if that doesn't work. NO WORRIES! "Hakuna matata" Just keep going and comeback to it in a couple of hours or next day. Keep up on learning.

I tried changing it to a class, it says task 3 is no longer passing. I tried removing the % sign, that doesn't work either. I think this is bugged.

Mike Dardano
Mike Dardano
2,256 Points

There seems to be a lot of us in the same boat. I suggest we try and pass this somehow and come back to it later.

I've just reported this to Treehouse, I'll reply to this forum post when I get a response :)

Guil Hernandez
STAFF
Guil Hernandez
Treehouse Teacher

Hi there,

The code challenge requires you to change the browser's default text and background colors. If you set the text color to black or the background color to white, it doesn't detect a color change so it throws the error.

Sorry about the confusion––I just updated the task description. :)

Guil