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,

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.

tag in HTML

It is one of the important elements of HTML. The

tag
consists of two mandatory attributes and some optional attributes.

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 tag.

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 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 are given below:

  • Size: It specifies the size or width of the box. If the user enters more characters than the specified size, the characters are automatically scrolled to the left.
    For Example:
  • 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:
  • Maxlength: It specifies the maximum number of characters that can be entered in the box by the user.
    For Example:
  • Min length: It specifies the minimum number of characters that can be entered in the box by the user.
    For Example:
  • Value: It specifies the default text that will appear in the box when the form is initially loaded in the browser.
    For Example:

Let's explain the 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 MCQ




Contact US

Email:[email protected]

Password hide in HTML
10/30