CSS same-line aligning

Mota picture Mota · Feb 8, 2009 · Viewed 32.4k times · Source

Is there an elegant way to align 3 elements left, center, and right on the same line?

Right now I'm using 3 <div>'s all with width:33%;float:left; and it's not working too well.

Answer

Johannes Weiss picture Johannes Weiss · Feb 8, 2009

that works for me:

<html>
  <head>
    <style>
      div.fl {
        float: left;
        width: 33%;
      }
      div.fr {
        float: right;
        width: 33%;
      }
    </style>
  </head>
  <body>
    <div class="fl">
      A
    </div>
    <div class="fl">
      B
    </div>
    <div class="fr">
      C
    </div>
  </body>
</html>

do you mean the same?