Input tag in HTML
- 24-07-2022
- Trung Minh
- 0 Comments
In this article we will learn how to use the input tag in HTML, this is a tag used to get data that the user enters.
The input tag has the function of creating a field for the user to enter input data.
The input tag is used together with the form tag to declare an input control that allows the user to enter data.
An input field can change in many ways, depending on the property passed.
1. How to use the input . tag
Example : Login form with input fields
<form> <h1> Login </h1> Username: <input type="text" name="username"> <br /> Password: <input type="passwword" name="passwword"> <br /> <input type="submit" name="submit" value="Login"> </form>
We can see that, with different values of the type attribute, the input field is displayed in different ways.
2. Some attributes of the input . tag
Attribute type
Type is the most important attribute of an input tag, it determines the functionality of that input tag.
Some values of type:
-
text
: text input field. -
password
: the password input field, the input characters will be masked with * characters. -
checkbox
: checkbox box. -
radio
: Cell radio button -
submit
: button to submit the form.
Some values in HTML5 :
-
number
: Type number -
url
: Site path type -
email
: Email type
There are many more values, but here I only list some of the most commonly used values.
Attribute value
Value is also a very important attribute of the input tag, it specifies the value of the input tag.
Example: the value attribute of the input . tag
<form> <h1> Login </h1> Username: <input type="text" name="username" value="Nhập username" > <br /> Password: <input type="passwword" name="passwword" value="Nhập password"> <br /> <input type="submit" name="submit" value="Đăng Nhập"> </form>