HTML <input type="password"> (original) (raw)
Last Updated : 23 May, 2026
The HTML element is used to create a password field in a form. The entered characters are hidden or masked for security purposes.
- Used to accept secure password input by hiding entered characters.
- Created using and commonly used in login and registration forms.
- Supports attributes like placeholder, required, and maxlength.
**Syntax:
**Note: We can add the tag for improved accessibility.
**Example: Using the HTML to create a password field where characters are masked, enhancing security by hiding sensitive information like passwords from plain view.
HTML `
HTML input type="password" Example
<form action="/action_page.php" method="post">
<label for="email">Email:</label>
<input type="email" name="email"
placeholder="Email Address"
required pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$">
<br>
<br>
<label for="paswword">Password:</label>
<input type="password" name="password"
placeholder="Password" required>
<br>
<br>
<input type="submit" value="Login">
</form>
`
**Note: Always ensure that forms containing sensitive information, such as passwords, are served over HTTPS to protect user data.
Best Practices for HTML Password Input
Here are a few tips for using :
- **Password Input in HTML Forms: Use to collect password information securely in HTML forms. This masks the entered text for privacy.
- **Hide Password in HTML: Password masking is done automatically with , preventing the password from being visible in plain text and enhancing security.