How to align HTML DIV side by side horizontally using CSS

Last Reply on Aug 08, 2012 05:46 AM By Mudassar

Posted on Aug 08, 2012 05:41 AM

hi

 i have created a web page in which i had use div

i have created a div whose height =100px and widht=300px

and another div with same property the problem is the 2nd div is coming below the 1st one it should come next to it

wt should i do to bring both of them side by side.

Posted on Aug 08, 2012 05:46 AM

You need to give Float to first DIV and margin to second

 <div style="width:300px;height:100px;float:left;background-color:yellow">
    </div>
    <div style="width:300px;height:100px;background-color:red;margin-left:300px">
    </div>

Demo