Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to left align and right align two div tags?

Tags:

html

alignment

What is the best way to right align and left align two div tags on a web page horizontally next to each other? I would like an elegant solution to do this if possible.

like image 552
Daniel Kivatinos Avatar asked Apr 07 '09 23:04

Daniel Kivatinos


People also ask

How do I make two divs left and right?

Using float and marginThe left div is styled with width:50% and float:left – this creates the green colored div that horizontally covers half of the screen. The right div is then set to margin-left:50% – this immediately places it to the right of the left div.

How do I align two divs?

The most common way to place two divs side by side is by using inline-block css property. The inline-block property on the parent placed the two divs side by side and as this is inline-block the text-align feature worked here just like an inline element does.


1 Answers

<div style="float: left;">Left Div</div> <div style="float: right;">Right Div</div> 
like image 89
Marcel Guzman Avatar answered Sep 18 '22 07:09

Marcel Guzman