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

Float and clear properties in css

What do these mean Float: right And Clear:both

Why do we use float and clear ?? What is its function? Please also explain the meaning of the code above

2 Answers

I've found CSS Tricks really handy for search stuff I haven't quite understood. https://css-tricks.com/almanac/properties/f/float/

Hi Akhter!

The float property specifies whether or not an element should float while the clear property is used to control the behavior of floating elements. For an example the float property can be used to wrap text around images. By giving an image a float:right value you can simply move it to the right side of the text.

The clear property is used to control the behavior of floating elements because by nature elements after a floating element will flow around it. The clear property specifies on which sides of an element floating elements are not allowed to float.

Cheers, Igor