title: Centering Content in DIV within HTML
body: <p>This is a common request. However, I'm going out of my mind. </p>
  
  <pre><code>    &lt;style type="text/css"&gt;
          html, body { height: 100%; margin:0px; padding:0px; }
          #content { margin-left: 50%; margin-right: 50%; width:900px; }
      &lt;/style&gt;
  </code></pre>
  
  <p>...</p>
  
  <pre><code>&lt;body style="min-height:100%; height:100%; position:relative;"&gt;
    &lt;header style="min-height:200px;"&gt;
        &lt;div style="height:50px; background:url(http://www.mydomain.com/images/bg.gif) repeat-x;"&gt;&amp;nbsp;&lt;/div&gt;
        &lt;div style="height:300px; background:url(http://www.mydomain.com/images/bg2.jpg) repeat;"&gt;
          &lt;div class="content" style="height:300px; background:url(http://www.mydomain.com/images/masthead-back.jpg) no-repeat;"&gt;
            &lt;img alt="Hello" src="http://www.mydomain.com/images/logo.png" /&gt;
            Welcome.
          &lt;/div&gt;
        &lt;/div&gt;
  
        &lt;div id="nav"&gt;
          &lt;ul class="navs"&gt;
            &lt;li&gt;&lt;a href="Main.aspx"&gt;Home&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="ContactUs.aspx"&gt;Contact&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="AboutUs.aspx"&gt;About Us&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/header&gt;
  
    &lt;article class="content" style="padding-bottom:60px;"&gt;
      This is the main content
    &lt;/article&gt;
  
    &lt;footer style="position:absolute; bottom:0px; width:100%; height:60px; background-color:black;"&gt;
      &lt;div class="content"&gt;
        &lt;a href='#'&gt;Privacy&lt;/a&gt;&amp;nbsp;|&amp;nbsp;&lt;a href='#'&gt;Terms of use&lt;/a&gt;
       &lt;/div&gt;
    &lt;/footer&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>I want my header, artcle, and footer items to be centered within the body. But, I want the content within the header, article, and footer to be left-aligned. What am I doing wrong, everything is currently just left-aligned. However, its not centered within the screen.</p>