Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,185 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%; }