In CSS3 float property is used to moves the targeted image or any
other element to left or right.It is very useful and interesting
feature in css.This is used in
multicolumn layouts, navigation toolbars
from lists, and table-like alignment without tables.
There are following values for floating property
1) left
2) right
3) none
Float left
<
style
type
="
text/css
"
>
div
{
border
:
1px solid black
;
padding
:
10px
;
width
:
50%
;
}
div img
{
float
:
left
;
margin
:
10px
;
}
<
/style
>
<
div
>
<
img
src
="
example.jpg
"
alt
="
blog-img
"
>
In this block image is floating to left.
In this block image is floating to left.
In this block image is floating to left.
In this block image is floating to left.
In this block image is floating to left.
In this block image is floating to left.
In this block image is floating to left.
In this block image is floating to left.
In this block image is floating to left.
In this block image is floating to left.
In this block image is floating to left.
In this block image is floating to left.
In this block image is floating to left.
In this block image is floating to left.
In this block image is floating to left.
In this block image is floating to left.
<
/div
>
Output of above code

Float right
<
style
type
="
text/css
"
>
div
{
border
:
1px solid black
;
padding
:
10px
;
width
:
50%
;
}
div img
{
float
:
right
;
margin
:
10px
;
}
<
/style
>
<
div
>
<
img
src
="
example.jpg
"
alt
="
blog-img
"
>
In this block image is floating to right.
In this block image is floating to right.
In this block image is floating to right.
In this block image is floating to right.
In this block image is floating to right.
In this block image is floating to right.
In this block image is floating to right.
In this block image is floating to right.
In this block image is floating to right.
In this block image is floating to right.
In this block image is floating to right.
In this block image is floating to right.
In this block image is floating to right.
In this block image is floating to right.
In this block image is floating to right.
In this block image is floating to right.
<
/div
>
Output of above code

Float none
When float none property is used the image or box will display where it occurs in between the content.
<
style
type
="
text/css
"
>
div
{
border
:
1px solid black
;
padding
:
10px
;
width
:
50%
;
}
div img
{
float
:
none
;
margin
:
10px
;
}
<
/style
>
<
div
>
<
img
src
="
example.jpg
"
alt
="
blog-img
"
>
In this block image is floating to none.
In this block image is floating to none.
In this block image is floating to none.
In this block image is floating to none.
In this block image is floating to none.
In this block image is floating to none.
In this block image is floating to none.
In this block image is floating to none.
In this block image is floating to none.
In this block image is floating to none.
In this block image is floating to none.
In this block image is floating to none.
In this block image is floating to none.
In this block image is floating to none.
In this block image is floating to none.
In this block image is floating to none.
<
/div
>
Output of above code

Comment here
If you have any query, if you want to know something about any of technical course related to computer science field, if you have any suggestion about relevant to uploaded content or if you anything wrong here (any mistake in content) than please contact us. Keep in mind, comment should be according to community guidelines.