Categories
HTML Tutorials

Password fields

A password field is a special text field that doesn’t display what the user types. Each keystroke is represented on the screen by a placeholder character, such as an asterisk or a bullet, so that someone looking over the user’s shoulder can’t see what they type. You create a password field by using the <input> element with the type attribute set to password, as follows:

<!DOCTYPE html>
<html lang="en">
  <head> </head>
  <body>
    <form method="post">
      <ul>
        <li>
          First Name:
          <input type="text" name="firstname" size="30" maxlength="25" /><br><br>
        </li>
        <li>
          Last Name:
          <input type="text" name="lastname" size="30" maxlength="25" /><br><br>
        </li>
        <li>
          Password:
          <input type="password" name="psswd" size="30" maxlength="25" />
        </li>
      </ul>
    </form>
  </body>
</html>
  • First Name: 
  • Last Name: 
  • Password: 

Password fields are programmed like text fields. You can see how a browser replaces what you type with bullets.

Note: Depending on the browser’s default settings, some browsers replace the text with asterisks or some other character.