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

CSS

Cannot remove margins. margin-top: 0; margin-bottom: 0; margin-right: 0; margin-left: 0;

I am trying to remove Margins and Padding. But even when i enter the below css it will not remove the left margin!

{ margin-top: 0; margin-bottom: 0; margin-right: 0; margin-left: 0;
}

What element are you trying to style?

Sorry the question was vague, I was getting frustrated.

How to build a website. Challenge Task 2 of 4

Select ID Gallery. Then, remove the margin, padding and bullet points.

...CSS id gallery { margin: 0; }...

It gives the error message "Bummer! looks like onside has been removed, try removing the other side.

So I tried this:

...CSS id gallery { margin-top: 0px; margin-bottom: 0px; margin-right: 0px; margin-left: 0px; }...

Still no luck. Where am i going wrong?

Any help would be great. I am sure is semantics, but I can't see where.

1 Answer

So, it's asking you to select the ID gallery. To do this in CSS you need to use the hash symbol to identify the "gallery" image element.

Example HTML below. In this example the img tag was given an ID equal to gallery. To style this in CSS you need to use the # to identify an id.

<img src="img/whateverimage.jpg" id="gallery">

And here's the CSS that you need to style the above HTML (also the answer to your initial question):

#gallery {
  margin: 0;
  padding: 0;
  list-style-type: none;
}

Now, if the image tag was named with a class instead of an ID, you would need to put a . in front of your CSS to identify the element, like so:

<img src="img/whateverimage.jpg" class="gallery">
.gallery {
  margin: 0;
  padding: 0;
  list-style-type: none;
}

Hopefully that helps.