Use floating elements to create columns in HTML and CSS

Description

The following code shows how to use floating elements to create columns.

Example


<!--from  w w  w.  j av a  2  s  .  co  m-->
<!DOCTYPE html>
<html>
<head>

<style type="text/css"> <!-- styles for two columns -->
h2 { text-align: center; }
p { text-align: justify; padding: 2%;}
p.floatleft { float: left; width: 46%; }
p.floatright { float: right; width: 46%; }
</style>
</head>
<body>
<h2>Points Of Interest</h2>
<p class="floatleft">
This is a test.
This is a test.
This is a test.
This is a test.
This is a test.
This is a test.
This is a test.
This is a test.
This is a test.

</p>
<p class="floatright">
This is a test.
This is a test.
This is a test.
This is a test.
This is a test.
This is a test.
This is a test.
This is a test.
This is a test.
This is a test.
This is a test.
This is a test.

</p>
</body>
</html>

Click to view the demo

The code above generates the following result.

Use floating elements to create columns in HTML and CSS
Home »
  HTML CSS Tutorial »
    Layout »
      Float
HTML CSS Tutorial Float
Create columns floating left in HTML and CS...
Float div left with width and height settin...
Float left and right for three columns layo...
Float left and right with other content in ...
Float left in HTML and CSS
Float right in HTML and CSS
Float right inside a container in HTML and ...
Make list item float left in HTML and CSS
Use floating elements to create columns in ...