The type="password" attribute in the HTML <input> element is used when you want the user to enter a password, where the characters typed by the user are masked (typically displayed as dots or asterisks). This is primarily for security and privacy reasons, so sensitive information like passwords cannot be easily seen.
When a form containing an input field with type="password" is submitted, the actual password (not the masked characters) is sent to the server. It behaves just like other text inputs in terms of styling, but the content is not visible on the screen.
password-field.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Password Input Example</title> </head> <body> <form action="https://httpbin.org/post" method="POST"> <label for="password">Enter your password:</label> <input type="password" id="password" name="user_password" required autocomplete="off"> <button type="submit">Submit</button> </form> </body> </html>
Whatever the data you enter on the password field is masked and not shown. You can confirm the same from below screen.
Previous Next Home
No comments:
Post a Comment