Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML text and password input fields have difference size internet explorer

Tags:

html

I am using this form setting for my login form :

<tr>
     <td class="label"> Username:</td>
     <td> <input id="id_username" type="text" name="username" maxlength="30" /></td>
</tr>
<tr>
     <td class="label"> Password:</td>
     <td> <input a="text" type="password" name="password" id="id_password" /></td>
</tr>

when using firefox both input boxes having the same size. However when I am on IE 9 , the password field is smaller.

What is the best way to get rid of this behavior ?

like image 832
Nuno_147 Avatar asked Jul 17 '12 08:07

Nuno_147


People also ask

What is the difference between an input type text and input type password in an HTML form?

Using password inputs. Password input boxes generally work just like other textual input boxes; the main difference is the obscuring of the content to prevent people near the user from reading the password.

How do you change the size of a password field in HTML?

The size attribute specifies the width of a password field (in number of characters). The default value is 20. Tip: To set or return the maximum number of characters allowed in the password field, use the maxLength property.

What is the default size for a text field?

The size attribute specifies the width of a text field (in number of characters). The default value is 20.

What should be the input type for password in HTML?

The <input type="password"> defines a password field (characters are masked). Note: Any forms involving sensitive information like passwords should be served over HTTPS.


2 Answers

Use CSS to apply a fixed width value to the elements, for example:

.fixed-input {
    width: 150px;
}
....
<input class="fixed-input" id="id_username" type="text" name="username" maxlength="30" />
like image 188
johngirvin Avatar answered Sep 22 '22 09:09

johngirvin


i was having the same problem. i added the width style and they still looked different.

it turned out that the padding and border color were also not the same for text and password inputs and this was causing the difference.

make sure you set the following style attributes for both password and text inputs:

width: 200px;
font-family: sans-serif;
font-size: 15px;
padding: 3px;
border: 1px solid black;
like image 22
user1828392 Avatar answered Sep 24 '22 09:09

user1828392