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 How to Make a Website Styling Web Pages and Navigation Make a CSS Image Gallery

Matthew Cahn
Matthew Cahn
6,301 Points

Not sure what you want me to do. Here's my code: img { width: 100% } What did I do wrong?

The images in the example fill the element. What did I do wrong?

css/main.css
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 {
  width: 100%
}
Wayne Priestley
Wayne Priestley
19,579 Points

Your also missing the semicolon after 100%

Lukas Coffey
Lukas Coffey
20,382 Points

^^ True. Because it's at the end of the declaration it won't affect the output, but if you add anymore properties, it will make all of those invalid.

Wayne Priestley
Wayne Priestley
19,579 Points

What do you mean

it's at the end of the declaration it won't affect the output

it won't pass the challenge unless its added, like this.

img {
  max-width: 100%;
}
Lukas Coffey
Lukas Coffey
20,382 Points

Oh you're talking about the challenge, my bad. I'm thinking in terms of a user stylesheet, thanks for clarification.

3 Answers

Hugo Paz
Hugo Paz
15,622 Points

Hi Matthew,

You need to set the max-width:100%

Lukas Coffey
Lukas Coffey
20,382 Points

Hello Matthew,

When you specify width: 100% for an element, it will always span 100% of it's containing element. Setting your width to max-width: 100% will allow it to only span the width of the element and not go any larger. Setting max-width is what they want you to do.

Matthew Cahn
Matthew Cahn
6,301 Points

Thanks, figured it out myself.