Let an image float to the left/right of the text, when clicking on two buttons:
The cssFloat property sets or returns the horizontal alignment of an element.
Note: The CSS "float" property is called "cssFloat" in JavaScript, because "float" is a reserved word in JavaScript.
Note: If there is too little space on a line for the floating element, it will jump down to the next line that has enough space.
The cssFloat property is supported in all major browsers.
Return the cssFloat property:
Set the cssFloat property:
Value | Description |
---|---|
none | The object/element is not floated. This is default |
left | The object/element will float to the left in the parent element |
right | The object/element will float to the right in the parent element |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Default Value: | none |
---|---|
Return Value: | A String, representing the horizontal alignment of an element |
DOM Version | DOM Level 2 |
Change the cssFloat property of a DIV element:
CSS tutorial: CSS Float