HTML Password

HTML password is the data entry element to enter values that have to be hidden from other than the   user. The typed characters are hidden by replacing each typed character with a * or . .   The length of the password can be restricted by specifying the maximum length attribute. Use of input type password prevents over-the-shoulder password theft.

Syntax – HTML Input Type Password

This input type is basically a textbox or a text field in an HTML form and is created by using INPUT tag that hides the typed characters behind asterisk (*) or a dot (.) depending on the user agent and the operating system.  For input type password TYPE attribute is set to value “PASSWORD” to indicate that the control will accept any characters from a user but will display a password character for the whole length of the typed text.

<INPUT TYPE=”PASSWORD” [other attributes]>

Attributes- HTML Input Type Password

HTML input type password control has the following attributes.


The TYPE attribute is used to define the type of control to be added in the HTML form. In this case the value is ‘PASSWORD’


This attribute is used to give identification to the password control in a web form element. The ID must be an alphanumeric string. The ID value for each field of web form must be unique. This ID is used in a script to manipulate the data entered by a user in an input type password.


The NAME attribute is used to give name to the password control that is used to access its values by the associated php or asp script file. The data is passed as keyword-value pairs. It is like a variable name holding a value entered by a user.


The SIZE attribute is used to define the number characters for the width of the password field. It is the width of the password control visible to a visitor in the web form. If the user types more characters than the width of the password control then these excess characters will be automatically left scrolled. The extra characters can be accessed by pressing the right arrow key.


This attribute defines how many characters can be typed in the password. The control will not allow the user to enter any more characters than the value set in MAXLENGTH attribute.


The VALUE attribute represents the password typed in by the user in the password HTML control. If you wish to have a default value to appear when the HTML form renders in the browser window, you can specify it in the VALUE attribute.  The default value can be deleted and replaced with a new value.

Example of HTML Input Type Password
    <FORM  action="addperson.php" method="post">
    Your Name
    <input type="text"  Name="name" MAXLENGTH="50">
    Email ID
    <input type="text"  Name="email" SIZE="20">
    Enter Password
	<input type="PASSWORD"  Name="pwd" SIZE="30" VALUE="Hello" MAXLENGTH="10" >
HTML input type password