input type='password' - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:input

Introduction

The password value for the type attribute creates an input element for entering a password.

The following table lists the additional attributes that are available when the type attribute is set to password.

Many of the attributes are shared with the text type and work in the same way.

Attribute Description
maxlengthSpecifies the maximum number of characters that the user can enter into the password box.
pattern Specifies a regular expression pattern for the purposes of input validation.
placeholder Specifies a hint to the user as to the kind of input that you expect.
readonly If present, this attribute makes the password box read-only, and the user cannot edit the content.
required Specifies that the user must enter a value for the purposes of input validation.
size Specifies the width of the element, expressed as the number of characters that are visible in the password box.
valueSpecifies the initial value for the password.

Using the password Type

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
   <head> 
      <title>Example</title> 
   </head> 
   <body> 
      <form method="post" action="http://example.com/form"> 
         <p> 
            <label for="name">
                Name: <!-- w  w  w .ja v  a  2s .  c  om-->
               <input value="java2s.com" id="name" name="name"> 
            </label> 
         </p> 
         <p> 
            <label for="password">
                Password: 
               <input type="password" placeholder="Min 6 characters" id="password" name="password"> 
            </label> 
         </p> 
         <p> 
            <label for="fave">
                Fruit: 
               <input value="CSS" id="fave" name="fave"> 
            </label> 
         </p> 
         <button type="submit">Submit Vote</button> 
      </form>  
   </body>
</html>

Related Tutorials