开发者

center tag not centering in IE7

i have this code and tried a few things but nothing wants to centre it in IE7?? all is ok with chrome and FF

&l开发者_开发问答t;div id='div_phone_big'></div>
<div id='div_longgray_gradient'>
<form>
   <table class='menu_bar_table' width='100%'>
     <br></br>
     <tr>
     <center>
        <span class='spn_big_lightblue_rbc'>RAINBOW</span><span class='spn_big_black_rbc'>CODE</span>
     </center>
     </tr>
     <br></br>
     <tr>
     <center>
        <span class='spn_med_yellow_rbc' >THANK YOU,YOUR FORM HAS BEEN SUBMITTED</span>
     </center>
     </tr>
</table>
</form>
</div>

the two span tags have no alignment set in the CSS

what am i doing wrong please? thank you


Things you're doing wrong:

  • You must have a td inside each tr: <tr><td> .. </td></tr>.
  • Using <center> is bad - it's deprecated. You should be instead using margin: 0 auto, or text-align: center for inline content.
  • Using tables for layout: Why not use tables for layout in HTML?
  • <br></br> is not correct. Use <br /> instead: why is <br /> different from <br></br> in XHTML?


Don't use center tag, it's deprecated. Use CSS instead. You can do something like this:

<td style="text-align:center">data</td>

You forgot to add tag inside your . If you want to study the anatomy of a table go here http://w3schools.com/html/html_tables.asp

<tr> 
    <td style="text-align:center">
        <span class='spn_big_lightblue_rbc'>RAINBOW</span>
    </td>
    <td style="text-align:center">
        <span class='spn_big_black_rbc'>CODE</span> 
    </td>
</tr> 
<tr> 
    <td style="text-align:center" colspan="2">
        <span class='spn_med_yellow_rbc' style="margin-left:auto;margin-right:auto;">THANK YOU,YOUR FORM HAS BEEN SUBMITTED</span> 
    </td>
</tr>

Also, don't use table for layout. Table is intended for tabular data, use CSS instead.


I might be wrong, but I think that you can't use <center> inside a <tr>.

Instead, use either the align attribute for the tr, or use CSS to center it

<tr align="center">
  <td>text</td>
</tr>

or

<tr style="text-align: center;>
  <td>text</td>
</tr>


tag doesn't center when some of his children uses the "float" property. Good Luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜