Make list item float left in HTML and CSS

Description

The following code shows how to make list item float left.

Example


<html>
<head>
<style type='text/css'>
ul {<!-- w ww . j  a v  a  2s.c  om-->
list-style: none;
border-bottom: thin solid black;
height: 21px;
}
li {
text-align: center;
float: left;
margin: 0 10px;
border: thin solid black;
width: 100px;
}
</style>
</head>
<body>
<ul>
<li><a href='http://www.google.com'>Google</a></li>
<li><a href='http://www.yahoo.com'>Yahoo</a></li>
<li><a href='http://www.ebay.com'>Ebay</a></li>
<li><a href='http://www.wrox.com'>Wrox</a></li>
</ul>
</body>
</html>

Click to view the demo

The code above generates the following result.

Make list item 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 ...