Computer >> Computer tutorials >  >> Programming >> HTML

How do we take password input in HTML forms?


To take password input in HTML form, use the <input> tag with type attribute as a password. This is also a single-line text input but it masks the character as soon as a user enters it.

How do we take password input in HTML forms?

Example

You can try to run the following code to take password input in HTML forms −

<!DOCTYPE html>
<html>
   <body>
      <head>
         <title>HTML Forms</title>
      </head>
      <p>Add your details:</p>
      <form>
         Student Username:<br> <input type="text" name="name">
         <br>
         Password:<br> <input type="password" name="password">
         <br>
      </form>
   </body>
</html>