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 Basics (2014) Basic Layout Width and Height Properties

tarkonis
tarkonis
1,036 Points

I don't understand the repercussions of the topic discussed in this video.

For example:

Adding width: 960px property to the primary/secondary content class rule sets the width of those divs to 960px;

Then, you add some padding to the left and right sides to give some "separation" from the margin (I don't understand why you do this either but take it at face value).

So far so good, the div is 960px + its padding giving a total width of 1060px.

What's the problem here? Why do I have to take away 50 pixels from the content area of the div, to make allowances for the 50px of padding I just added to make some separation from the margin?

This lesson has not made a lot of sense to me.

It's difficult because he can't quite explain why this matters without going into greater detail regarding advanced layout etc etc --

So this lesson had me scratching my head for the same reason. #guilhatessimplemath

5 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 90,845 Points

I think all Guil is saying is be wary of how much width and height you put on the content area of your elements, especially when you have one main container of a specific size. Each element has a default amount of width for content area, margin and padding and settng your own amounts ensures you have control of layout and separation.

But these are all up to you and under your control. :)

Pavle Lucic
Pavle Lucic
10,801 Points

You will run into issues, for example if overlap container element.

The video is demonstrative to show off the logic of box model and how the padding is affecting on elements dimension.

Cynthia (Sunni) Freyer
Cynthia (Sunni) Freyer
828 Points

As you keep moving forward in theme development, you'll eventually come across a use case where you'll discover that you're grateful for understanding that padding affects the inside of the box while margin affects the outside. Trust me. It will happen.

Christopher Andrew Kemur
Christopher Andrew Kemur
7,709 Points

i think the problem, the standart width for content div is 960px. so if you adding the padding the width will be more than 960px. but with border-box property you will get width as defined in the width property. so the layout won't be messed up by the padding you just added.

it just my opinion, please correct me if i'm wrong :)

Morten Larsen
Morten Larsen
12,263 Points

Anyone capable to explain me what we are trying to archieve in this video? I dont seem to find any answers i the above replys to opening posts questions?