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

how do you set the image to its maximum width

the only way to change the size of an image is through html but this code challenge is only for main.css

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.numbers-01.jpg{
  width: 50%
  max-width: 160px;
  height: auto;
}

img.numbers-0.2.jpg{
  width: 50%; 
  max-width: 160px
  height: auto;
}

img.numbers-0.6.jpg{
  width: 50%;
  max-width: 160px;
  height: auto;
}

img.numbers-0.9.jpg{
  width: 50%;
  max-width: 160px;
  height: auto;
}

img.numbers-0.12.jpg{
  width: 50%;
  max-width: 160px;
  height: auto;
}

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

First, CSS is generally how we change an image's size. Second, we can select all images at once just by selecting the img tag. Then we set a max-width to 100%. That way it will always fill the parent container. Take a look at my code. This is what you need for step 1.

img {
  max-width: 100%;
}
Sarah Jee Watson
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Sarah Jee Watson
UX Design Techdegree Graduate 28,197 Points

In this case, you're trying to make all the images fill space within their parent element, so all you need is one style.

img { max-width: 100%; }