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 Layout The CSS Box Model Padding, Borders, and Margins

/* Complete the challenge by writing CSS below */ .header { padding: 20px 25px; } Padding isn't working

Challenge: Set the top padding to 20px and bottom to 25px

/* Complete the challenge by writing CSS below */
.header {
   padding: 20px 25px; 
<!DOCTYPE html>
<html lang="en">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Developer Diane's blog</title>
  <link rel="stylesheet" href="page.css">
  <link rel="stylesheet" href="style.css">
    <div id="logo">Developer Diane’s Blog</div>
    <section class="intro">
      <h1>The verdict is in. CSS Layout is great!</h1>
      <p>I’ve been working with CSS for a while now, and I have to say, it’s pretty awesome. I love being able to separate content from presentation, and to keep all my styles in an external stylesheet.</p>
      <p>I’ve had a pretty good grasp on the basics for a while now, but I needed to learn more about how to control layout with my CSS. Understanding CSS layout meant first exploring the parts of the CSS box model.</p>
    <section class="featured">
      <h2>The CSS Box Model</h2>
      <p>There are lots of great resources online to help you learn the CSS Box Model. I like the CSS Tricks article <a href="https://css-tricks.com/the-css-box-model/" target="_blank">The CSS Box Model</a> by Chris Coyier. To quote the author:</p>
      <blockquote>At the risk of over-repeating myself: <strong>every element in web design is a rectangular box.</strong></blockquote>
      <p>That’s right! Every HTML element is considered by the browser to be a rectangular box.</p>
      <p>The CSS Box Model consists of four properties: content, padding, border, and margin. I've included a graphic from Coyier’s article to illustrate this principle.</p>
      <p class="clear">It’s pretty easy to understand the Content portion of the box model. The content is whatever your HTML consists of. It could be a paragraph full of text, or a bulleted list, or an image.</p>
      <p>Beginning developers may have some trouble keeping the other parts of the box model straight, so let’s examine them one by one.</p>
    <footer>©2020 Developer Diane.</footer>

You do not have the name of the ".header" class in your markup. You can rather use header {} or ID attribute #logo in your stylesheet.

Do not forget the clockwise notation while creating your padding.

1 Answer

You have selected a class called header rather than selecting the header element. Remove the period before header to fix this.

You also currently have the top and bottom padding set to 20px and the left and right padding set to 25px. Change your css like below to fix this.

header {
   padding: 20px 0px 25px; 

Thanks, that definitely clears things up. As for only using two variables, I thought that if you use a short-hand method of two, that it modifies "top", "bottom".

When using the short-hand method with only two variables, the first vaariable will apply to the top and bottom while the second variable you input will apply to the left and right.

If you use 3 inputs, then the first applies to top, the second applies to left and right and the third now goes to bottom.