Crus4

logo

What is input tag in HTML


The HTML input tag is used to collect the user’s data. That is why it is most important form element (because in the form we are collecting user’s input). The HTML <input> tag is used to create various types of form controls such as text fields, checkboxes, radio buttons, buttons, and more. It is a self-closing tag that doesn’t require a closing tag.

The <input> tag has a variety of attributes that can be used to customize the behavior and appearance of the form control. which includes:

  • type:- This attribute specifies the type of input control to be displayed, such as text, checkbox, radio, submit, etc.
  • name:- This type of attribute specifies the name of the input control, which is used to identify the input when the form is submitted.
  • value:- This attribute defines the initial value of the input control.
  • required:-This attribute is used to specify the input field must be filled out before the form can be submitted.
  • disabled:- This type of attribute specifies that the input control should be disabled and the user cannot interact with it.
  • readonly:- This attribute specifies that the input control is only available to read and the user cannot edit its value.
  • placeholder :- This attribute defines the some kind of hint that describes the expected value of input field.

So, these are some mainly used HTML input attributes.

Learn more about input tag attributes, in our HTML input tag attributes.

Here is an example of an HTML <input> element that creates a text field:

<html>
<head>
<body>
<h2>Enter your name in the below box</h2>
<input type="text" name="username" placeholder="Enter your username">
</body>
</html>

In the above code, the type attribute is set to "text", which creates a text input field. The name attribute is set to "username", which identifies the input control, when the form is submitted. The placeholder attribute is used to display a hint text to the user about what kind of value should be entered in the text field.


Share this post!

What is input tag in HTML

One thought on “What is input tag in HTML

Leave a Reply

Your email address will not be published. Required fields are marked *