Display and Float

Display and float are CSS properties that I have decided to group together because they are often used together on the same element. Display specifies how the element will element appears in organizational terms to the browser. Float tells more about the alignment of the element.

CSS Display Property


  • Item 1
  • Item 2

While the display property has many possible values, inline and block are the most common. Normally lists appear vertical; however, when we set the display property to inline for the li class “inline”, we can see the list displayed horizontally. The inline will continue to place elements horizontally until they reach a width of their parent container element. If we wanted the list elements to appear on different vertical levels, we should have set the display property to block.

CSS Float Property


Sample Text 1
Sample Text 2

The example above is pretty straightforward. The float:left; simply means that when the “float” property is set to “left”, the element is aligned to the left. On the other hand, if the “float” property is set to “right”, the element is aligned to the right. We have only one big caution here. The div tag, if not specified, believes that it can take up the whole horizontal space. This is precisely why I define the “width” to “100px”. That pretty much sums up the display and float properties, and now we can move onto positioning.


If you enjoyed this resource, support me by sharing this page with others.
Share on Facebook
Share on StumbleUpon
Digg this
Tweet about this on Twitter
Share on Reddit

Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.