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.

CSS CSS Foundations The Box Model Width, Height and Overflow Properties

Box Model Challenge: Question 3 Box-sizing property.

I'm stuck on the Box Model Challenge Question 3 pertaining to box-sizing. I don't think I understand how I'm supposed to answer the question.

index.html
<!DOCTYPE html>
<html>
<head>
    <title>Width, Height and Overflow Properties</title>
    <link rel="stylesheet" href="page.css">
    <link rel="stylesheet" href="style.css">
</head>
<body>   
    <nav>
        <a href="#">About Me</a>
        <a href="#">My Work</a>
        <a href="#">Contact Me</a>
    </nav>
    <div class="main">
        <p>Veggies sunt bona vobis, proinde vos postulo esse magis kohlrabi courgette sorrel rock melon summer purslane soybean bitterleaf fennel.</p>
        <p>Pumpkin ricebean gourd cauliflower water chestnut garlic parsley bunya nuts earthnut pea tomato lettuce. Swiss chard chickpea burdock soybean soko cucumber garlic wakame pea arugula azuki bean turnip greens spinach eggplant.</p>
        <p>Arugula cress bitterleaf rutabaga potato burdock celery chard eggplant desert raisin.</p>
    </div>
</body>
</html> 
style.css
/* Complete the challenge by writing CSS below */
a {
  display: inline-block;
  width: 100px;
}
.main {
  box-sizing: 40px;
}

1 Answer

Alex Heil
Alex Heil
53,534 Points

hey Kathryn Notson , by default the css boxmodel works by adding padding to an element. means if you have a div that's 400px wide and you add 20px padding it will expand to 440px total (400px element + 20px padding on the left + 20px padding on the right).

however we can change this behaviour by changing the boxmodel to something called border-box. when we do so then the width we give the element (400px in this case) is not expanded, the padding is getting substracted automatically and we don't have to worry about it. to use it we write it like this:

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

if you add this to your challenge it should pass just fine. hope that helps and have a nice day ;)

Believe it or not, I did figure it out myself! Thanks anyway. The explanation helps.

I'm having a connection issue with the server @ SE Works, so I've had to restart this challenge several times this afternoon before completely it successfully.