float

The float property specifies whether a box should float to the left, right, or not at all.

Syntax

float: left | right | none | inherit
Initial: none
Applies To: all elements
Inherited: no
Percentages: NA
Media: visual

Values

float: value
Value Description
left Floated to the left while content flows on the right starting at the top
none Not floated
right Floated to the right while content flows on the left starting at the top

DOM

[window.]document.getElementById("element-id").style.cssFloat   = "float";
[window.]document.getElementById("element-id").style.styleFloat = "float";

cssFloat is used by Chrome, Firefox, Opera, and Safari.

styleFloat is used by Internet Explorer and Opera.

Example | left

Example | none

Example | right

Example | DOM

External

W3C Cascading Style Sheets, level 1

W3C Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification