Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

EricBrian

macrumors 6502a
Original poster
Jul 30, 2005
656
7
Heya.

So, I have an issue... I have 2 divs within a div and of those 2 divs, div 2 should be right aligned. Can anybody tell me how to do this?

The HTML is:

<div>
<div id="d1" style="display:inline;"> this one should be left aligned.</div>
<div id="d2" style="display:inline;border:1px solid black;"> this one should be right aligned.</div>
</div>


Thanks for the help
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
There's at least 3 ways to get that effect. What method to use partly depends on the specifics of the layout. Here's one.

CSS:
Code:
#d1 {
 float: left;
 width: 50%;
}
#d2 {
 float: right;
 width: 50%;
 border: 1px solid black;
}

HTML:
<div>
<div id="d1"> this one should be left aligned.</div>
<div id="d2"> this one should be right aligned.</div>
</div>
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.