Menu
Coddy logo textTech

Password Field

Part of the Fundamentals section of Coddy's HTML journey — lesson 38 of 60.

In HTML, a password field is a type of input field used to collect passwords from users.

It is similar to a regular text input field, but the characters typed into a password field are masked, usually displayed as asterisks or dots. This is to prevent others from seeing the password as it is being typed.

To create a password field, you use the <input> tag with the type attribute set to "password".

Here's the basic syntax for creating a password field in HTML:

<input type="password" name="passwordfield">
challenge icon

Challenge

Easy

Create an HTML document that includes a form with a password field. The password field should have the name of “userpassword", a type of password" and a placeholder that says "Enter your password". Set the maximum length of the password field to 20 characters.

Cheat sheet

A password field is an input field that masks typed characters (displayed as asterisks or dots) to hide passwords from view.

Create a password field using the <input> tag with type="password":

<input type="password" name="passwordfield">

Additional attributes can be used:

  • placeholder - shows hint text
  • maxlength - limits character count
<input type="password" name="userpassword" placeholder="Enter your password" maxlength="20">

Try it yourself

<!DOCTYPE html>
<html>
    <body>
        <!-- Write code here -->
    </body>
</html>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals