Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS float property

CSS float property

Example

Float an image to the right:

img

{

float:right;

}

Try it »

There are more examples at the bottom of this page.


Property definition and usage

The float property specifies whether a box (element) should float.

Note: Absolutely positioned elements ignore the float property!

Default value: none
Inherited: no
Version: CSS1
JavaScript syntax: object.style.cssFloat="left"

Browser support

The numbers in the table indicate the first browser version that supports this property.

property
float 1.0 4.0 1.0 1.0 7.0

Attribute values

Value Description
left The element floats to the left.
right The element floats to the right.
none Default value. The element does not float and is displayed where it appears in the text.
inherit Specifies that the value of the float property should be inherited from the parent element.

More examples

Float the first letter of a paragraph to the left
Float the first letter of a paragraph to the left and add a style to that letter.

Create a horizontal menu
Use floats to create a list of hyperlinks for a horizontal menu.

Create a table-less home page
Use floats to create a home page with a header, footer, left sidebar, and main content.


Related Articles

CSS Tutorial: CSS Float