How to align two div

How to align two div

This example explains how to perform the alignment of two text fields.

With this example we would show how to perform the alignment of two boxes (in this case we use two div tags). "Alignment" means placing the two boxes horizontally next to each other. They will have the same height.

CSS

div#container {
	width: 90%;
	border: 1px solid #000;
	text-align: center;
}
div.split2 div {
	float: left;
	width: 50%;
}
div.wide {
	clear: left;
}


HTML Code

<div id="container">
<div class="split2">
   <div>
      <h1>Column title no. 1</h1>
      <p>The content of the first column.</p>
   </div>
   <div>
      <h1>Column title no. 2</h1>
      <p>The content of the second column.</p>
   </div>
</div>
<div class="wide"><p>This div has a clear set to prevent the float of the two columns of text.<br />
   <a href="http://www.icelab.eu/en/blog/css-4/how-to-align-two-div-4.htm">View full example</a></p></div>
</div>

Publication details

Category: CSS

Published by: loryzz on date: 29.02.2008 23:14:24

Last edit by: loryzz on date: 24.06.2009 17:58:41

Statistics

Details  This article has been viewed 7.244 times.

Send to

add to digg add to reddit add to furl add to facebook add to delicious add to google add to stumbleupon add to technorati add to ask add to live

Ratings

  • Currently 100; ?>/ TOTALSTARS
  • 1
  • 2
  • 3
  • 4
  • 5

Comments

Details 0 user comments, 0 still waiting.

Leave a comment

All comments must be approved by site administrator.
Please write comments on topic. Spam will be never approved.


Confirmation code

Please take a look to image and insert character into the form field.