HTML Element Style How to - Float li right








Question

We would like to know how to float li right.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#pinkbar {<!--  w  w w.j  a  v  a  2  s  .co m-->
  width: 100%;
  height: 25px;
  background: pink;
}

ul.nav {
  list-style-type: none;
  float: right;
  margin: 0;
}

ul.nav li {
  float: right;
}
</style>
</head>
<body>
  <div id='pinkbar'>
    This is a test.
    <ul class="nav">
      <li>Testimonials</li>
      <li>About</li>
      <li>Fees</li>
    </ul>
  </div>
</body>
</html>

The code above is rendered as follows: