Wednesday, June 15, 2011

Visual formatting model - DIV HTML Floats Issue

A float is a box that is shifted to the left or right on the current line. The most interesting characteristic of a float (or "floated" or "floating" box) is that content may flow along its side (or be prohibited from doing so by the 'clear' property). Content flows down the right side of a left-floated box and down the left side of a right-floated box.

Here is showing what happens when a float overlaps borders of elements in the normal flow.

Image showing a floating image
that overlaps the borders of two paragraphs: the borders are
interrupted by the image.  

A floating image obscures borders of block boxes it overlaps.
The following example illustrates the use of the 'clear' property to prevent content from flowing next to a float.
Example(s):
Assuming a rule such as this:

p { clear: left }
formatting might look like this:
Image showing a floating
image and the effect of 'clear: left' on the two paragraphs.   
Both paragraphs have set 'clear: left', which causes the second paragraph to be "pushed down" to a position below the float — "clearance" is added above its top margin to accomplish this.

Content Source - http://www.w3.org/TR/CSS2/visuren.html

No comments:

Post a Comment