CSS CSS Layout Basics Page Layout with the Float Property The Float Challenge Solution

Amandeep Pasricha
Amandeep Pasricha
Front End Web Development Techdegree Student 7,860 Points

Why did he apply the float to only the col class and not individually to primary and secondary?

In my solution, I applied a float left property to primary and float right property to secondary. That made more sense to me, because you aren't supposed to apply the float to the specific columns?

If you apply a float: left to col in general, then that would mean both columns would be floated to the left, which isn't what we want. We want one to go on the left and the other to go on the right.

Gabriel Pierce-Lackey
Gabriel Pierce-Lackey
Treehouse Moderator 10,916 Points

Yes, most definitely. Beyond these two ways there are even more ways to achieve this. Another that comes to mind quickly being flex box.

You will learn multiple ways to do just about everything, as you get better and more comfortable you will learn what ways are the best for what you are trying to do.

1 Answer

Gabriel Pierce-Lackey
MOD
Gabriel Pierce-Lackey
Treehouse Moderator 10,916 Points

The float left to both will work in a way where it push the first column to the left, then the second column against that the first one to the left as well. Giving the same result with less code. Which is always good.