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 trialLuca Di Pinto
8,051 PointsWhy using clear: float???
Hi everybody,
I don't understand why do we have to use the declaration clear: left for the class col...
Can you explain me the meaning of using it in this context?
Thanks
3 Answers
Christoph Walpert
3,752 PointsIn this challegene you need to .col { float: left; } in Order to have the columns next to each other. For an exercise just try changing only the width. You will see, they wont move next to each other. But if you float them, then they move next to each other. Assigning it to the class .col, is due to the fact that it is parent class of both primary and secondary? :)
That helped?
Patryk Bernasiewicz
Courses Plus Student 10,281 PointsThere's no clear: left applied to the .col class in this video, there's only a float: left applied and it's to make the columns stick next to each other on the layout.
Luca Di Pinto
8,051 PointsSorry I made i mistake! I wanted to say float: left and not clear: float! :-)
Erik Nuber
20,629 PointsI haven't watched the video to answer your question, so will rely on the other reply from Patryk saying that there is no clear: float in the video itself.
When you float something, it allows other objects to flow around them. For example, if you float an image: right, it will allow text to flow around the left side of the object.
If you clear the float on either left or right side, or both, it changes how things will then flow.
When you clear: left you clear elements floated to the left. So an element floated to the left will end up on a line by itself with whatever is after it appearing below that floated item.
The same goes for clear: right on a floated right object.
You can clear both which means if you have two items floated both left and right you can clear each side using clear: both.