<div align=center>hello</div>
or use span:
<span align=center></span>

解决方案 »

  1.   

    用相对定位<div id=maindiv style="position:absolute;width:300;height:200;background:red"></div>
    <script>
    <!--
     function pos(){
    document.all.maindiv.style.left=(parseInt(document.body.offsetWidth)-parseInt(document.all.maindiv.style.width))/2;
     document.all.maindiv.style.top=(parseInt(document.body.offsetHeight)-parseInt(document.all.maindiv.style.height))/2;
    }
      pos();
    //-->
    </script>
      

  2.   

    <div id=maindiv style="position:absolute;width:300;height:200;background:red"></div>
    <script>
    <!--
    maindiv.style.left=(document.body.clientWidth-maindiv.clientWidth)/2;
    maindiv.style.top=(document.body.clientHeight-maindiv.clientHeight)/2
    //-->
    </script>
      

  3.   

    <HTML>
    <script>
    function divcenter(){
    document.all.mxh.style.left=(Math.round((document.body.scrollWidth-200)/2)).toString()+"px"
    }
    </script>
    <body onload="divcenter()" onresize=divcenter()>
    <table width=100%>
    <tr>
    <td>test
    </td>
    </tr>
    </table>
    <div id=mxh style="position:absolute;left:200px;top:30px;width:200px;height:200px;background-color:navy;border:2px">测试文字</div>
    </HTML>
      

  4.   

    <HTML>
    <script>
    function divcenter(){
    document.all.mxh.style.left=(Math.round((document.body.scrollWidth-200)/2)).toString()+"px"
    }
    </script>
    <body onload="divcenter()" onresize=divcenter()>
    <table width=100%>
    <tr>
    <td>test
    </td>
    </tr>
    </table>
    <div id=mxh style="position:absolute;left:200px;top:30px;width:200px;height:200px;background-color:orange;border:2px">不随窗口变化,永远居中的层</div>
    </HTML>