CSS Layout How to - Float right and float left in same line








Question

We would like to know how to float right and float left in same line.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#header {<!--  w  ww . j a  v  a 2  s.c  o m-->
  background: #e0e0e0;
}

span.previous {
  float: left;
}

span.next {
  float: right;
}

p.month {
  text-align: center;
}
</style>
</head>
<body>
  <div id="header">
    <span class="previous">**</span> 
    <span class="next">**</span>
    <p class="month">May</p>
  </div>
</body>
</html>

The code above is rendered as follows: