Click to return to the DHTML, HTML     
firstChild Property     font Attribute | font Pro...     DHTML Properties    
Web Workshop  |  DHTML, HTML & CSS

float Attribute | styleFloat Property


Sets or retrieves on which side of the object the text will flow.

Syntax

HTML{ float: sFloat }
Scriptingobject.style.styleFloat [ = sFloat ]

Possible Values

sFloat String that specifies one of the following values:
noneObject displays where it appears in the text.
leftText flows to the right of the object.
rightText flows to the left of the object.

The property is read/write with a default value of none; the cascading style sheets (CSS) attribute has a default value of none and is not inherited.

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see Dynamic Properties.

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 move 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. In Internet Explorer 5, DIV and SPAN objects are assigned a width by default and will render if a width is not specified.

Example

This example shows how the float attribute affects the flow of the text. The sphere image floats to the left of the text, and the cone floats to the right.

Sample Code

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

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

This example uses inline scripting and the styleFloat property to swap images when the mouse moves over the button.

Sample Code

<IMG ID=oSphere SRC="sphere.jpeg" STYLE="float:left">
<IMG ID=oCone SRC="cone.jpeg" 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> 

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
A, ADDRESS, APPLET, B, BIG, BLOCKQUOTE, BUTTON, CENTER, CITE, CODE, currentStyle, custom, DD, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FORM, Hn, HR, I, IFRAME, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, ISINDEX, KBD, LABEL, LEGEND, LI, LISTING, MARQUEE, MENU, OBJECT, OL, P, PRE, RT, RUBY, runtimeStyle, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, style, SUB, SUP, TABLE, TEXTAREA, TT, U, UL, VAR, XMP


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.