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 CSS Basics (2014) Basic Layout Styling the "Wildlife" div with Background Properties

I don't understand the question on step 5

Finally, give .wildlife the property and value that forces any padding and border widths into its total width and height.

Do I just set all padding and border values to 0%?

style.css
/* Complete the challenge by writing CSS below */

.wildlife {
 background-image: url("img/bear.jpg"); 
 background-repeat: no-repeat; 
 background-position: center; 
 background-size: cover; 

}
index.html
<!DOCTYPE html>
<html>
  <head>
    <title>Lake Tahoe</title>
    <link rel="stylesheet" href="page.css">
    <link rel="stylesheet" href="style.css">
  </head>
  <body> 
        <div class="primary-content t-border">
            <p class="intro">
                Lake Tahoe is one of the most breathtaking attractions located in California. It's home to a number of ski resorts, summer outdoor recreation, and tourist attractions. Snow and skiing are a significant part of the area's reputation.
            </p>
            <a class="callout" href="#more">Find out more</a>
      <div class="wildlife">
        <h2>Check out all the Wildlife</h2>
        <p>
          As spawning season approaches, the fish acquire a humpback and protuberant jaw. After spawning, they die and their carcasses provide a feast for gatherings of <a href="#mink">mink</a>, <a href="#bears">bears</a>, and <a href="#eagles">bald eagles</a>.
        </p>
      </div><!-- End .wildlife -->
            <a class="callout" href="#wildlife">See the Wildlife</a>
        </div><!-- End .primary-content -->
  </body>
</html>

2 Answers

Colin Bell
Colin Bell
29,679 Points

It's looking for a css rule that will keep padding and borders within an elements total height/width, as opposed to adding padding and borders on top of the set width/height.

Notice these two boxes have the exact same stylings except for the box-sizing property.

The first one stays at 200px by 100px (the initial values set) and adds the padding and border to the inside of the box.

The second one starts out at 200px by 100px and adds on 20px of padding to each side and 7px of border width to each side, resulting in a box that is actually 254px by 154px

  • 254px results from (200px + 20px padding on left + 20px padding on right + 7px border on left + 7px border on right)
  • 154px results from (100px + 20px padding on top + 20px padding on bottom + 7px border on top + 7px border on bottom)

click to view full size box-sizing

Vince Brown
Vince Brown
16,249 Points

Hey Luc Sengers , What the question is referring to here is setting

.wildlife {
    box-sizing: border-box;
}

This is touching on the CSS box model. Which is essentially a box that wraps around HTML elements, and it consists of: margins, borders, padding, and the actual content.

This can cause some people to trip up because say you have 2 elements you want to take up the screen so you float them and set them to 50% . This will work, but now lets say you have a 1px border on one of the elements. Now that is not truly 50% it it 50% + 1px so it will no longer fit. This is where "border-box" comes into play, It takes borders and padding and automatically factors them into the width so we dont have to be compensating for borders and paddings in our css.

Hope that Helps Cheers, Vince