kacpi2442 kacpi2442 - 4 days ago 5
HTML Question

How to center input of form in table? HTML

I want to put inputs in a one row.
Sorry for my poor english.



<table border='1' cellpadding="25" style='border-collapse: collapse;border-color: silver;'>
<tr style='font-weight: bold;'>
<td width='350' align='center'>
<h2>Register:</h2><br>
Login: <input type="text" name="login" maxlength="20" size="25" /><br>
Password: <input type="password" name="password" size="25" maxlength="32" /><br>
Repeat password: <input type="password" name="password2" size="25" maxlength="32" /><br><br>
</td></tr></table>




Answer

I think you are trying to get all this aligned in the center.For that we have to use the the "tr" tag defines a row in an HTML table and "th" tag which defines a header cell in an HTML table.Try the following code :

<html>
<body>
<h2 align="center">Register</h2>
    <table align="center">
        <tr>
            <td>Login</td>      
            <td><input type="text" name="login" align="middle"/></td>
        </tr>
        <tr>
            <td>Password</td>
            <td><input type="password" name="pass" align="middle"/></td>
        </tr>
        <tr>
            <td>Repeat Password</td>
            <td><input type="password" name="rpass" align="middle"/></td>
        </tr>   

    </table>

Also we use the align property for table and the new rows we create to get what you desire.

Comments