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

When to use float?

Hello!

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?

thanks

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!