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 Layout Techniques Float Layout Creating a Horizontal Menu

David Rabideau
seal-mask
.a{fill-rule:evenodd;}techdegree
David Rabideau
Front End Web Development Techdegree Student 7,612 Points

Setting Margins

I'm curious as to why Guil used a margin shorthand for .main-logo and then three separate margin rules for the .main-nav li in this lesson. Is there a specificity reason? Why not just use the shorthand on .main-nav li?

Code from lesson below:

.main-logo {
    margin: 0 50px 0 0;
}

.main-nav li {
    margin-top: 15px;
    margin-right: 10px;
    margin-left: 10px;
}

Wouldn't the shorthand for margin on .main-nav li be cleaner code?

.main-nav li {
    margin: 15px 10px 0;
}

Just trying to understand for my own learning.

2 Answers

I have not taken the course, but from a web developer's point of view, I can tell you nothing is different. I personally prefer shorthand due to the ease of use, but some people mix it up every now and again. :)

David Rabideau
seal-mask
.a{fill-rule:evenodd;}techdegree
David Rabideau
Front End Web Development Techdegree Student 7,612 Points

Yeah I'm thinking maybe he just did it to cover both ways of writing out margins, he just never explained why he did. I personally like the shorthand better as well. I just wanted to make sure there wasn't any technical reason to use one over the other. Thanks!

Nope :) It all processes the same! No technical reasons.

Aleksey Polivanyy
Aleksey Polivanyy
1,679 Points

I think its for study reason, to remind students about this ruls.