An HTML page is made up of various elements—one being the <input> element. The HTML input element is primarily to create HTML forms.
In other words, an HTML <input> tag is used to create the data fields on forms that enable users to enter information.
In this article, we will discuss the following topics:
- What is an HTML <input> tag?
- HTML input types
- Input type text and password
- Input type checkboxes and buttons
- Input type file
- Input type color
- Input type date
- Input type week
- Input type email
What Is an HTML <input> Tag?
The HTML <input> tag is used to declare an input element within a form. It is used to create several input fields in the form to collect the data from the user.
The following is an example of simple text input:
HTML Input Types
The “type” attribute of the HTML <input> element specifies the type of input field that will be displayed. There are several types of input fields, and we will cover the vital ones.
Input Type Text and Password
The <input type=”text”> defines the one-line text input field and <input type= “password”> defines the one-line password input field.
This is what it should look like:
Input Type Checkboxes and Buttons
Type “ “
Checkboxes enable the user to select multiple options
Radio enables the user to select one option
Defines a submit button to send the data to the server
You will then see the following:
Input Type File
The <input type= “file”> is used to select one or multiple files from the user storage device.
This will appear next:
Input Type Color
The <input type=”color”> defines an input field with a specific color.
This is what you’ll see next:
Input Type Date
The <input type=”date”> is used for an input field that contains the date.
Using this code will produce the following:
Input Type Week
The <input type=”week”> code enables the user to select a week and a year.
This coding results in the following:
Input Type Email
The <input type=”email”> is used for an input field that should have an email address.
This will produce the following result:
Get skilled in HTML5 and CSS3 with the Full Stack Java Developer Master's Program. Click to check out the program details!
This article on HTML input offered a brief input tag introduction, which also included visual guides that illustrated how to create them. Although we discussed several input types that are required to create an HTML form, certification is highly recommended if you are truly looking to take your coding career to the next level. Simplilearn’s Full Stack Java Developer is an all-encompassing program that will teach you essential Java development skills from the ground up, and provide you with hands-on exercises and projects. Students gain a magnitude of skills through this comprehensive program, including how to test and deploy code, store data using MongoDB, and much more.
If you’re an aspiring web and mobile developer, HTML training will broaden your skills and career opportunities.
Do you have any questions for us? Please mention leave them in the comments section, and we'll have our experts answer them for you as soon as possible.