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

Moses Finlay
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Moses Finlay
Full Stack JavaScript Techdegree Graduate 24,800 Points

Why not just use float?

Instead of

.col {    
    display: inline-block;
    width: 50%; 
    margin-right: -4px;
    vertical-align: top;
    padding-left: 1em;
    padding-right: 1em;
}

why not just use

.col {
   display: inline-block;
   width: 45%;
}
.primary {
    float: right;
}

2 Answers

David Olson
David Olson
8,690 Points

Hi Moses,

Your right, a float would definitely work. I think the point of this exercise is to understand how the different display settings work though since there will be situations where a float will not meet your needs.

Jonathan Kuhl
Jonathan Kuhl
26,133 Points

An interesting point David, because I too simply used "float" to move the divs into position, though unlike Moses, I used "float left" in the .col rule. It floated both to the left of the container div. Setting them a width of 50%, made them centered because the container div itself is centered (margin: 0 auto;)

But I suppose there is merit to learning multiple approaches to a situation.

Brady Borkowski
Brady Borkowski
7,495 Points

I'm going through the track a second time now and thought the same thing, but realized it's just good to understand the concepts and how these elements behave.

Understanding what may be considered the long or wrong way to do something still has value in the long run, but it's definitely confusing for beginners going through the videos for the first time. It's strange to me that the first "do it yourself" type of challenge for this track involves using a method that isn't really practiced, especially when they typically mention somewhere that it's not the typical practice.