Tuesday, 3 January 2012

Aligning Text in the Div tag with diffrent alignment such as some with right and some with left.

Sometimes you get a requirement that you need to align some text right and some left. but you get a little bit error when u aligning to the right as rather than coming in the same line it will come in the next line.
So to fix it you have to fix it by giving div clear after the align-Right and align-Left.

For e.g.
<html>
<head>
<style type="text/css">
  .alignLeft {  float: left;  }
  .alignRight{  float: right; }
  .clearAll  {  clear: both;  } 
 </style>
</head>
<body>
<div id="textbox">
  <div class="alignLeft ">Text on the left.</div>
  <div class="alignRight">Text on the right.</div>
</div>
<div class="clearAll"></div>
</body>
</html>

Note: Here the <div class="clearAll"></div> is playing a vital role.

No comments:

Post a Comment