Javatpoint Logo
Javatpoint Logo

Password hide in HTML

In this article, we will learn how to hide the password field in a form using HTML. At the beginning of this article, we will learn some HTML basics, <form> tag and password element. After that, we can understand this concept with some examples.

What do you mean by HTML?

HTML stands for Hypertext Markup language. The latest HTML version is HTML5. HTML is the standard markup language for building and designing web pages.

In HTML, we can use various commands called tags. Tags are instructions that are embedded directly into the text of an HTML document. Each HTML tag specifies some action that the browser displays on a web page.

<form> tag in HTML

It is one of the important elements of HTML. The <form> tag consists of two mandatory attributes and some optional attributes.

<Input> element

The input element is used to insert various controls in the form, such as text boxes, files, passwords, emails, etc. The input element is applied in the form using <input> tag.

<input type = "password" >

Password can also be the part of the data entered in HTML forms. Instead of displaying original characters, either asterisk (*) or dots (.) are shown when a password is entered. Thus the entered characters are masked or hidden. To make a textbox that can hide the entered characters, the type attribute of <input> element should be set to "password."

Syntax:

All the attributes used with textbox are also supported by password input element.

The various attributes used with <input type = "password" > are given below:

  • Size: It specifies the size or width of the <input type = "password" > box. If the user enters more characters than the specified size, the characters are automatically scrolled to the left.
    For Example: <input type="password" size ="20" >
  • Placeholder: It specifies a short hint that describes an input field's expected value (e.g., a sample value or a short description of the expected format). This hint is displayed in the input field before the user enters a value.
    For Example: <input type="password" size ="20" placeholder=" Enter the value of Password">
  • Maxlength: It specifies the maximum number of characters that can be entered in the <input type = "password" > box by the user.
    For Example: <input type="password" size ="20" maxlength ="20" placeholder="Password">
  • Min length: It specifies the minimum number of characters that can be entered in the <input type = "password" > box by the user.
    For Example: <input type="password" size ="20" Minlength ="20" placeholder="Password">
  • Value: It specifies the default text that will appear in the <input type = "password" > box when the form is initially loaded in the browser.
    For Example: <input type="password" size ="20" Minlength ="20" placeholder="Password" value =" Enter Password" >

Let's explain the <input> element with the help of various examples:

Example 1:

Output:

The output of this example is given below:

Password hide in HTML

Example 2:

Output:

The output of this example is given below:

Password hide in HTML
Next TopicHTML Calculator





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA