View Single Post
  #1 (permalink)  
Old 04-02-2008, 02:21 AM
ablaye's Avatar
ablaye ablaye is offline
WMG Sheriff

 
Join Date: Feb 2007
Posts: 285
iTrader: (0)
ablaye is on a distinguished road
Default How do you center a div?

Been struggling with this for the last few days.
I have a div section that I would like to have centered on the page.
Code:
<div style="background-color:#EFEDE9; border-top:2px solid #D1D1E1; border-right:2px solid #D1D1E1; border-left:2px solid #D1D1E1; text-align:center;margin:0 auto;">
Want this section to be centered!
</div>
It works fine on IE6 and IE7 but on Firefox, the div does not appear centered.

I tried to include the div code in a table that I had centered but it still did NOT work.
The code:
Code:
<table cellpadding="0" cellspacing="0" border="0" align="center">
<tr><td align="center">
<div style="background-color:#EFEDE9; border-top:2px solid #D1D1E1; border-right:2px solid #D1D1E1; border-left:2px solid #D1D1E1; text-align:center;margin:0 auto;">
Want this section to be centered!
</div>
</td></tr>
</table>
still did NOT get the div centered.

I don't know what else to try.
If anyone has any suggestions, please let me know.
Reply With Quote
Sponsored Links
Register and sign in to hide this ad block