elibraryportal Logo

CSS Float Example(float and clear)

CSS float property is used to Move the elements to the left or right.This elements manily used for images and layouts.



CSS Float Properties

Property Values
clear left, right, both, none, inherit
float left, right, none, inherit

CSS Float Property Values

Value Description
none It is a default value.
left This is used to float the element to the left.
right This is used to float the element to the right.
initial It is sets to the property to its initial value.
inherit This is used to inherit this property from its parent element.

Example1 - float: right;

This example specifies that an image should float to the right in a text:

CSS TutorialsCSS control the layout of color of the text, the style of fonts, the spacing between paragraphs,background images or colors are used and also multiple web pages at once.. CSS are Mainly work on how HTML elements are to be displayed on screen.



Example:-

Test it Now

Example2 - float: left;

This example specifies that an image should float to the left in a text:

CSS TutorialsCSS control the layout of color of the text, the style of fonts, the spacing between paragraphs,background images or colors are used and also multiple web pages at once.. CSS are Mainly work on how HTML elements are to be displayed on screen.



Example:-

Test it Now

Clear Property

The clear property is used to what elements can float beside the cleared element and on which side.

Example:-

Test it Now

Navigation Menu

Use the float to create a horizontal menu with a list of hyperlinks :

Test it Now

Web Layout Example

Use the float property for web layouts Website.

Example:-

Test it Now