Warning: Undefined array key "StartingPoint" in /customers/f/f/0/safaribears.de/httpd.www/content.php on line 107 Warning: Cannot modify header information - headers already sent by (output started at /customers/f/f/0/safaribears.de/httpd.www/content.php:107) in /customers/f/f/0/safaribears.de/httpd.www/content.php on line 115 Warning: Undefined variable $WEB_ROOT in /customers/f/f/0/safaribears.de/httpd.www/content.php on line 118 Warning: Cannot modify header information - headers already sent by (output started at /customers/f/f/0/safaribears.de/httpd.www/content.php:107) in /customers/f/f/0/safaribears.de/httpd.www/content.php on line 118 Warning: Undefined array key "HTTP_ACCEPT_LANGUAGE" in /customers/f/f/0/safaribears.de/httpd.www/content.php on line 169 CSS Tutorial - Positioning - clear
sample pic Image #1 sample pic Image #2 sample pic Image #3 Now, imagine, there are several pictures, and there is always just a short description afterwards, which should flow around the image. I just put the pictures in the page, and then add the description after each image, and have the images with float:left; floating on the left side of the container, right?

That does not look right, huh? The property float just means that everything that comes afterwards will go around the image. Everything. We have to give another property to make elements stop flowing around, and that is the property 'clear'. Let's take the same box as above again, with the images and the text, and put that text Now, imagine, ... in it's one box inside of the main box, and add the style add clear:left; to it.

sample pic Image #1 sample pic Image #2 sample pic Image #3
Now, imagine, there are several pictures, and there is always just a short description afterwards, which should flow around the image. I just put the pictures in the page, and then add the description after each image, and have the images with float:left; floating on the left side of the container, right?

clear:left; tells that text to not flow to anything on the left of it. It could still flow to another image or div that will come afterwards, like a footer. If we don't want elements to flow at all, then we use clear:both;. At first, I always use that, unless I want it to flow to something specifically. Well, I am still not satisfied with the looks of our little box, the descriptions are hanging all at the top, but at least the longer text behaves now. We have to put the short image subtitles together with the image into a box:



sample pic Image #1
sample pic Image #2 - this description is a lot longer, and it should behave nicely, meaning it should flow around the image, too. We still have the style float:left attached to the images, remember? The clear property is attached to the boxes (the divs), not to the images (I used <div style="clear:both;"> for that). You can also see that the boxes are just as tall as the text needs it, the images protrude at the bottom.
sample pic Image #3
Now we have all the images with their respective description sitting in their own boxes, inside of the big box. For illustration I have made all inner boxes have a colored border.