Apr 262012
 

I frequently wish to have a table centered using nothing but css. I ALWAYS seem to have trouble remembering/figuring out how to do it. Apparently I’d forgotten to write it down in the past and I just had to use it again. After looking around a bit, I found what I had been using previously; well, parts of it then I put it all back together again. Anyway, below is what should serve as an example.

<div id="outer">
  <div id="inner">

    <table>
      <tr>
        <td>Some Text</td>
        <td>Some Text</td>
        <td>Some Text</td>
        <td>Some Text</td>
        <td>Some Text</td>
      </tr>
    </table>

  </div>
</div>

<style>

.outer {
  text-align: center;
  width: 100%;
}

.inner {
  display: inline-block;
}

</style>

I put this in the PHP category mostly because I didn’t have an HTML or CSS category, but all that crap belongs in the PHP category anyway since PHP is THE only language for web programming. I just added an HTML category, so I’m switching this to that category.

 Posted by at 6:42 pm