Trusted answers to developer questions

What is float property in CSS?

Get Started With Machine Learning

Learn the fundamentals of Machine Learning with this free course. Future-proof your career by adding ML skills to your toolkit — or prepare to land a job in AI or Data Science.

The CSS float property states how the element should float. For example, it can specify the position where the element should be placed.

Note: The element can be anything i.e., an image, a paragraph, a button, etc.

Syntax

The syntax for the float CSS property is:

float: value;

CSS float property can have the following values:

  • None: There will be no effect on the position of the element i.e., the element will not float.

  • Right: The element floats to the right of its container

  • Left: The element floats to the left of its container

  • Inherit: The element inherits the float value of its parent

Float: None

The following example displays the image when the float is set to none:

Float: Right

The following example makes the image float to the right of the container:

Float: Left

The following example makes the image float to the left of the container:

RELATED TAGS

css
css float
float
Copyright ©2024 Educative, Inc. All rights reserved
Did you find this helpful?