<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: How to position two elements left and right aligned purely using CSS?</title>
	<link>http://ask.metafilter.com/85648/How-to-position-two-elements-left-and-right-aligned-purely-using-CSS/</link>
	<description>Comments on Ask MetaFilter post How to position two elements left and right aligned purely using CSS?</description>
	<pubDate>Sat, 08 Mar 2008 11:31:13 -0800</pubDate>
	<lastBuildDate>Sat, 08 Mar 2008 11:31:13 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: How to position two elements left and right aligned purely using CSS?</title>
		<link>http://ask.metafilter.com/85648/How-to-position-two-elements-left-and-right-aligned-purely-using-CSS</link>	
		<description>HTML/CSS Design Filter! How do I position two elements in the same line but, one left aligned, and the other right aligned using just CSS? &lt;br /&gt;&lt;br /&gt; I&apos;m a bit of a n00b to pure-css design, so forgive my ignorance!&lt;br&gt;
&lt;br&gt;
I&apos;m trying to position the page title and the logo in the header of the page. I want the title to be left aligned, and the logo to be right-aligned. Oh, and I want to make it a flexible layout, i.e. I&apos;d like the page to expand/contract as the browser window size changes. &lt;br&gt;
&lt;br&gt;
I&apos;ve been &lt;a href=&quot;http://www.brainjar.com/css/positioning/&quot;&gt;reading up&lt;/a&gt; a on purely css based design, but for the life of me I can&apos;t figure out how to accomplish this. &lt;br&gt;
&lt;br&gt;
Here&apos;s the &lt;a href=&quot;http://kmshiva.com/test/positioning.html&quot;&gt;link to the page.&lt;/a&gt; &lt;br&gt;
&lt;br&gt;
Also, any resources for learning more of this stuff are welcome.</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2008:site.85648</guid>
		<pubDate>Sat, 08 Mar 2008 11:19:11 -0800</pubDate>
		<dc:creator>ogami</dc:creator>
		
			<category>css</category>
		
			<category>html</category>
		
			<category>webdesign</category>
		
	</item> <item>
		<title>By: sanitycheck</title>
		<link>http://ask.metafilter.com/85648/How-to-position-two-elements-left-and-right-aligned-purely-using-CSS#1265565</link>	
		<description>The key to this is nested divs and floating.  I have taken your page and done a mockup &lt;a href=&quot;http://www.jkparker.ca/mefi/positioning.html&quot;&gt;here&lt;/a&gt;. You can click view source to see what&apos;s different from yours.&lt;br&gt;
&lt;br&gt;
What I changed:&lt;br&gt;
&lt;br&gt;
- Made the title and logo both their own div (instead of using span)&lt;br&gt;
&lt;br&gt;
- Made the title float left and the logo float right&lt;br&gt;
&lt;br&gt;
- Put in a &quot;clear&quot; div below the header. The clear is needed because when you use float, any other content that comes afterward will flow around the floated divs.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.85648-1265565</guid>
		<pubDate>Sat, 08 Mar 2008 11:31:13 -0800</pubDate>
		<dc:creator>sanitycheck</dc:creator>
	</item><item>
		<title>By: cowbellemoo</title>
		<link>http://ask.metafilter.com/85648/How-to-position-two-elements-left-and-right-aligned-purely-using-CSS#1265573</link>	
		<description>sanitycheck&apos;s got it.  float float float!</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.85648-1265573</guid>
		<pubDate>Sat, 08 Mar 2008 11:37:38 -0800</pubDate>
		<dc:creator>cowbellemoo</dc:creator>
	</item><item>
		<title>By: ogami</title>
		<link>http://ask.metafilter.com/85648/How-to-position-two-elements-left-and-right-aligned-purely-using-CSS#1265617</link>	
		<description>Cool. Thanks sanitycheck. &lt;br&gt;
&lt;br&gt;
I tried floating the logo to the right, but that didn&apos;t help. I didn&apos;t try floating the title to the left at the same too.&lt;br&gt;
&lt;br&gt;
Also, I&apos;ll remember the &apos;clear&apos; trick.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.85648-1265617</guid>
		<pubDate>Sat, 08 Mar 2008 12:13:08 -0800</pubDate>
		<dc:creator>ogami</dc:creator>
	</item><item>
		<title>By: drjimmy11</title>
		<link>http://ask.metafilter.com/85648/How-to-position-two-elements-left-and-right-aligned-purely-using-CSS#1265684</link>	
		<description>have you looked at Sanitycheck&apos;s example in IE? There&apos;s extra spacing between the header and the content.&lt;br&gt;
&lt;br&gt;
I&apos;m not saying this to be critical, but to point out how &quot;pure CSS&quot; works cross-browser. Which is to say, it really doesn&apos;t.&lt;br&gt;
&lt;br&gt;
I know you didn&apos;t ask this exactly, but the answer is, in my opinion, &quot;use a table.&quot;&lt;br&gt;
&lt;br&gt;
There is probably a way to do this without the &quot;clear&quot; div, like substituting an invisible [hr] or something. I just don&apos;t see the point of going through all these contortions for the sake of trendiness, when tables work so well.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.85648-1265684</guid>
		<pubDate>Sat, 08 Mar 2008 13:14:39 -0800</pubDate>
		<dc:creator>drjimmy11</dc:creator>
	</item><item>
		<title>By: sanitycheck</title>
		<link>http://ask.metafilter.com/85648/How-to-position-two-elements-left-and-right-aligned-purely-using-CSS#1265732</link>	
		<description>My example above was a quick-and-dirty 60-second mockup.  Yes, it sometimes takes a bit of tweaking to get CSS to render exactly the same on different browsers, but this doesn&apos;t mean you shouldn&apos;t use it.&lt;br&gt;
&lt;br&gt;
CSS has clear usability advantages over tables because it effectively separates the content from the markup.  This is especially important for accessiblity reasons (e.g. visually impaired users using screen readers).&lt;br&gt;
&lt;br&gt;
Here is a (nor very recent) article on the subject:&lt;br&gt;
&lt;a href=&quot;http://www.sitepoint.com/article/tables-vs-css&quot;&gt;http://www.sitepoint.com/article/tables-vs-css&lt;/a&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.85648-1265732</guid>
		<pubDate>Sat, 08 Mar 2008 14:24:36 -0800</pubDate>
		<dc:creator>sanitycheck</dc:creator>
	</item><item>
		<title>By: ogami</title>
		<link>http://ask.metafilter.com/85648/How-to-position-two-elements-left-and-right-aligned-purely-using-CSS#1265737</link>	
		<description>One of primary reasons I want to stop using tables for layout is because it&apos;s such a PITA to maintain. The billions of nested tables are a huge headache to keep track of. &lt;br&gt;
&lt;br&gt;
A purely CSS based design I guess is more pain up-front (atleast for someone who is not familiar with it), but I guess easier to maintain in the future.&lt;br&gt;
&lt;br&gt;
But, from what I hear, all those IE-specific hacks are quite a big PITA too!</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.85648-1265737</guid>
		<pubDate>Sat, 08 Mar 2008 14:43:35 -0800</pubDate>
		<dc:creator>ogami</dc:creator>
	</item><item>
		<title>By: Ridge</title>
		<link>http://ask.metafilter.com/85648/How-to-position-two-elements-left-and-right-aligned-purely-using-CSS#1265798</link>	
		<description>A second method of accomplishing the same thing: &lt;a href=&quot;http://www.martinridgway.com/webdev/tests/mefi/ogami/&quot;&gt;Linky&lt;/a&gt;. This method doesn&apos;t change your original HTML at all, and uses positioning rather than floats.&lt;br&gt;
&lt;br&gt;
Here&apos;s what I did:&lt;br&gt;
&lt;ol&gt;&lt;li&gt;Explictly declared &lt;code&gt;#header&lt;/code&gt; to be &lt;code&gt;position:relative&lt;/code&gt;&lt;/li&gt;&lt;br&gt;
&lt;li&gt;Gave &lt;code&gt;.logo&lt;/code&gt; a declaration of &lt;code&gt;position:absolute&lt;/code&gt; and then set its &lt;code&gt;top&lt;/code&gt; and &lt;code&gt;right&lt;/code&gt; positioning to be 0.&lt;/li&gt;&lt;/ol&gt;&lt;br&gt;
This does what you expect - sets the position of the image to the top and the right respectively, but importantly, &lt;em&gt;it does it in relation to its relatively-positioned container&lt;/em&gt;.&lt;br&gt;
&lt;br&gt;
In other words, because I set the position of &lt;code&gt;#header&lt;/code&gt; to &lt;code&gt;relative&lt;/code&gt;, I can move objects around inside that container to my hearts content, and not worry about them shifting off into the ether, or disturbing the document flow after &lt;code&gt;header&lt;/code&gt; is closed.&lt;br&gt;
&lt;br&gt;
Oh, I tested that code in FF2, IE7 and IE6. Works just fine, and no hackage required.&lt;br&gt;
&lt;br&gt;
Absolute positioning within a relative-positioned container is tricky to grasp at first, but man it&apos;s a powerful tool. One I use every day.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.85648-1265798</guid>
		<pubDate>Sat, 08 Mar 2008 16:38:36 -0800</pubDate>
		<dc:creator>Ridge</dc:creator>
	</item><item>
		<title>By: Ridge</title>
		<link>http://ask.metafilter.com/85648/How-to-position-two-elements-left-and-right-aligned-purely-using-CSS#1265801</link>	
		<description>Oh, I didn&apos;t test in Safari. Should be fine though.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.85648-1265801</guid>
		<pubDate>Sat, 08 Mar 2008 16:39:42 -0800</pubDate>
		<dc:creator>Ridge</dc:creator>
	</item><item>
		<title>By: kirkaracha</title>
		<link>http://ask.metafilter.com/85648/How-to-position-two-elements-left-and-right-aligned-purely-using-CSS#1265859</link>	
		<description>&lt;a href=&quot;http://meyerweb.com/eric/tools/css/reset/&quot;&gt;Resetting&lt;/a&gt; &lt;a href=&quot;http://developer.yahoo.com/yui/reset/&quot;&gt;CSS&lt;/a&gt; goes a long way towards resolving cross-browser/cross-platform differences. If you code for Firefox and Safari first, you&apos;ll get most of the way there. IE 6 causes the most trouble, and you can use &lt;a href=&quot;http://www.quirksmode.org/css/condcom.html&quot;&gt;conditional comments&lt;/a&gt; to keep the IE 6 fixes in a separate style sheet.&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://css.maxdesign.com.au/floatutorial/&quot;&gt;Floatutorial&lt;/a&gt; is a step-by-step guide to building a website with floats.&lt;br&gt;
&lt;br&gt;
&lt;q&gt;&lt;i&gt;Absolute positioning within a relative-positioned container is tricky to grasp at first, but man it&apos;s a powerful tool.&lt;/i&gt;&lt;/q&gt;&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.stopdesign.com/articles/absolute/&quot;&gt;Making the Absolute, Relative&lt;/a&gt; is a good explanation.&lt;br&gt;
&lt;br&gt;
You could also &lt;a href=&quot;http://orderedlist.com/articles/clearing-floats-the-fne-method&quot;&gt;float nearly everything&lt;/a&gt; and not use clearing divs.&lt;br&gt;
&lt;br&gt;
Advocating tables for layout over CSS in 2008 is silly. CSS has been a valid way to build layouts for &lt;a href=&quot;http://www.stopdesign.com/articles/throwing_tables/&quot;&gt;years&lt;/a&gt;.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.85648-1265859</guid>
		<pubDate>Sat, 08 Mar 2008 18:48:53 -0800</pubDate>
		<dc:creator>kirkaracha</dc:creator>
	</item><item>
		<title>By: ogami</title>
		<link>http://ask.metafilter.com/85648/How-to-position-two-elements-left-and-right-aligned-purely-using-CSS#1265883</link>	
		<description>Thanks Ridge.&lt;br&gt;
&lt;br&gt;
I guess some of the trouble I&apos;m having with CSS stems from with the Perl-ish philosophy of &quot;There Is More Than One Way To Do It&quot;, as opposed to the Python-ish &quot;There Is One Way To Do It&quot;. I still have nightmares of that one Perl project I worked on. However, I rather like CSS - it doesn&apos;t feel so hackish, quite the opposite actually.&lt;br&gt;
&lt;br&gt;
I think I&apos;ll go and check out those links kirkaracha suggested.&lt;br&gt;
&lt;br&gt;
P.S.: I just found &lt;a href=&quot;http://www.constructyourcss.com/&quot;&gt;this&lt;/a&gt; - it looks pretty cool and useful.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.85648-1265883</guid>
		<pubDate>Sat, 08 Mar 2008 19:26:02 -0800</pubDate>
		<dc:creator>ogami</dc:creator>
	</item>
	</channel>
</rss>
