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 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,547 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.