Float left in HTML and CSS

Description

The following code shows how to float left.

Example


<html>
<head>
<!--from  w  ww.  jav a  2 s  .  c  o  m-->

<style type="text/css">
body {
margin: 0px;
padding: 0px;
color: #000;
background-color: #ccc;
}


.myStyle {
float: left;
padding: 10px;
margin: 5px;
background-color: #fff;
border: 1px solid #000;
width: 15%;
}

</style>
</head>

<body>
<div class="myStyle">1</div>
<div class="myStyle">2</div>
<div class="myStyle">3</div>
<div class="myStyle">4</div>
</body>

</html>

Click to view the demo

The code above generates the following result.

Float left 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 ...