asp.net.ph

Skip Navigation LinksAbakada: Back to Basics > Language References > CSS Properties > Box Properties > float Property

float | styleFloat Property


Sets or retrieves whether the object floats, causing text to flow around it.

Syntax

CSS { float: 'none' | 'left' | 'right' }
Script object.style.styleFloat = sFloat ]

Possible Values

none Object will be displayed where it appears in the text.
left Text will flow to the right of the object.
right Text will flow to the left of the object.

The property is read/write with a default value of none; the CSS property has a default value of none and is not inherited.

Remarks

With a value of left or right, the object is treated as block-level ( that is, the display property is ignored ). For example, floating paragraphs allow the paragraphs to appear side-by-side on a page.

Objects following a floating object flow in relation to the position of the floating object.

The floating object is moved left or right until it reaches the border, padding, or margin of another block-level object.

DIV and SPAN objects must have a width set for the float attribute to render.

Example

The following example shows the float attribute affecting the flow of the text. The sphere image floats to the left of the text, and the cone floats to the right.

<img src="sample.jpg" style="float:left">
<img src="sample.jpg" style="float:right">

 Show me 

The following example demonstrates use of the styleFloat property. When the user mouses over the button, the images are swapped using inline scripting and the styleFloat property.

<img id=oSphere src="sphere.jpg" STYLE="float:left">
<img id=oCone src="cone.jpg" STYLE="float:right">
...
<button 
  onmouseover="oSphere.style.styleFloat='right';
  oCone.style.styleFloat='left'"
  onmouseout="oSphere.style.styleFloat='left';
  oCone.style.styleFloat='right'">Flip-flop images.
</button>

 Show me 

See Also

clear


Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph.

If you have any question, comment or suggestion,
please send us a note