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

Hardip Singh Nagi
Hardip Singh Nagi
4,758 Points

I don't know how to set an items margin to 0 where item has just 3 margins.

How to skip value of the side with no margin?

css/main.css
#Gallery li p a{
  margin: 0 0 30px 0 ;
  padding: 0 0;
  list-style: none;
}

a {
  text-decoration: none;
}

#wrapper {
  max-width: 940px;
  margin: 0 auto;
}

#logo {
  text-align: center;
  margin: 0;
}

h1, h2 {
  color: #fff;
}

nav a {
  color: #fff;
}

nav a:hover {
  color: #32673f;
}

h1 {
  font-family: "Changa One", sans-serif;
  font-size: 1.75em;
  font-weight: normal;
}

img
{
  max-width: 100%;
}

2 Answers

Owa Aquino
Owa Aquino
19,277 Points

Hi Hardip,

Just remember this:

1 value = all sides ( all sides )
2 value = first value is for top&buttom, second value is for left&right ( t&b - l&r )
3 value = first value is for top only, second value is for left&right, third value is for bottom only ( t - l&r - b )
4 value = first value is for top, second value is for right, third value is for bottom, fourth value is for left ( t - l - b - r )

Hope this help!

Cheers!

Hardip Singh Nagi
Hardip Singh Nagi
4,758 Points

Thanks Owa. Yes, I know about t r b l. But I have a challenge where i have to set all margins of an item to 0, and it has top, right and left margins, no bottom margin. Now how to skip or pass no value to b in t r b l?

Owa Aquino
Owa Aquino
19,277 Points

Hey Hardip,

You should use the 4 value margin.

margin : 15px 5px 0 5px; //top 15px left 5px bottom 0 right 5px

This makes the bottom margin to 0.

Owa Aquino
Owa Aquino
19,277 Points

You can also use 3 value margin

margin : 15px 5px 0; //top 15px left&right 5px bottom 0
Owa Aquino
Owa Aquino
19,277 Points

Also I see your ID on gallery is capitalize

#Gallery li p a{
  margin: 0 0 30px 0 ;
  padding: 0 0;
  list-style: none;
}

Anyway if you can't move on to the task 2 your answer should be like this

#gallery {
 margin: 0;
 padding: 0;
 list-style: none;
}
Hardip Singh Nagi
Hardip Singh Nagi
4,758 Points

Thanks a lot Owa! Yeah I figured that out, my mistake to use 'G'.