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

mrx3
mrx3
8,742 Points

I got a broken box error with CSS lint?

I have a class with padding and height in the same declaration, CSS below:

.header-section {
  padding-top: 3px;
  height: 115px;
  background-color: black;
}

The error from CSS lint says, "Using height with padding-top can sometimes make elements larger than you expect."

I did setup the box-sizing rule to.Is this something I should change, or is CSS lint being too picky? Thanks in advance for any answers.

1 Answer

Jacob Miller
Jacob Miller
12,466 Points

It's not really an error, just a warning. Your .header-section will take up 118px of space vertically because you have to add the 3px of padding to the 115px height.

If you use box-sizing: border-box, it will apply the padding to the inside of the element, making the header take up 115px of vertical space, with the 3px of padding applied inside of the element instead of outside of it. So in other words, it's just a warning to make sure you are aware of it, but you don't necessarily have to change it unless you want to.

mrx3
mrx3
8,742 Points

Thanks Jacob.