Skip to Content
CSS Display and Positioning

So far, you’ve learned how to specify the exact position of an element using offset properties. If you’re simply interested in moving an element as far left or as far right as possible on the page, you can use the float property.

The float property can be set to one of two values:

  1. left - this value will move, or float, elements as far left as possible.
  2. right - this value will move elements as far right as possible.
.boxes { width: 120px; height: 70px; } .box-bottom { background-color: DeepSkyBlue; float: right; }

In the example above, we float the .box-bottom element to the right. This works for static and relative positioned elements. See the result of the code below:

Floated elements must have a width specified, as in the example above. Otherwise, the element will assume the full width of its containing element, and changing the float value will not yield any visible results.



Set the float property of the .answer element to left.

Folder Icon

Take this course for free

Already have an account?