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 Layout Techniques Float Layout Why Floats are Used in Web Design

When to use float?


I have often wondered when it is best to use floats over position:relative/absolute.... Take for example 3 images that are in their respective divs. Divs are block elements, so initially each picture in a div is occupying its own line. However if I want to put all 3 pictures in one row, why should I think float:left can achieve the result I want. I can use the same example for links that children of list elements in an UL. The nature and use of float seems bizzare.

In fact do floats cause elements to end up in one row, how can I visualize the effect of float?


2 Answers

Kevin Kenger
Kevin Kenger
32,834 Points

I think this article from CSS-Tricks should be able to help you understand floats a little bit better.

Thanks Kevin!