To center an element (replacement for the deprecated <table align="center"> or <center> or <div align="center">)...
Put this in the <head> of your html document or your external CSS (in that case without the <style> tags of course).
Code:
<style type="text/css">
body { text-align: center; /*IE 5.x, 6 workaround */ }
#layout { width: 575px; /*or whatever you want, just set a width*/
margin-left: auto;
margin-right: auto;
}
p,th,td { text-align: left; /*to counter the workaround above and align the text to the left, otherwise all the text will be center-aligned */}
</style>
Put the <div id="layout"> around whichever elements you want centered; that is, use it as a "wrapper"...
For example:
Code:
<div id="layout">
<h1>Please login below:</h1>
<form action="login.php" id="login" method="post">
<table cellpadding="0">
<tr>
<th scope="row"><label for="username">Username</label></th>
<td><input type="text" id="username" name="username" size="15" maxlength="20" />
</tr>
<tr>
<th scope="row"><label for="pwd">Password</label></th>
<td><input type="password" id="pwd" name="pwd" size="15" maxlength="8" />
</tr>
</table>
</form>
</div>
Make sense? Hope this helps...
Bookmarks