We can see forms in our day-to-day life. When we go to a bank to make an
account, applying for a college that you dreamed of or for jobs, we use forms
to write a personal information and give it to personnel to process it. Just like
a physical form, HTML <form> collects the information and send it somewhere else.
<form action ="/example.html"
method="Post"></form>
In this example, the action attribute is to know where the information is sent
method attribute as request in the HTTP.
Tag/Attribute Name | Actual Formatted Tag | Description | Code |
---|---|---|---|
Input type, name | <input type> <input type="text" name="first-text field"> |
|
<form action=”/example.html” method=”POST”> <input type=”text” name=”first-text-field”> </form> |
Tag/Attribute Name | Actual Formatted Tag | Description | Code |
---|---|---|---|
label | <label> | To properly identify an <input> | <form action=”/example.html”method=”POST”> <label for=”toppings”>What do you want for your icecream?</label> <br> <input type=”text” name=”marshmallow” id=”toppings”> </form> |
Tag/Attribute Name | Actual Formatted Tag | Description | Code |
---|---|---|---|
input type="password" | <input type="password> | A string of characters to confirm user's identity | <form> <label for=”user-password”>Password</label> <br> <input type=”password” id=”user-password” name=”user-password”> </form> |
Tag/Attribute Name | Actual Formatted Tag | Description | Code |
---|---|---|---|
input type="number" | <input type="number"> | To let users type in a number | <form> <label for=”years”>Years of Experience</label> <br> <input id=”years” type=”number” step=”1”> </form> |
Tag/Attribute Name | Actual Formatted Tag | Description | Code |
---|---|---|---|
input type="range" | <input type="number" min="0" max="100" step="1"> | To limit what numbers the users could type which will create a slider. Notes:
|
<form> <label for=”years”>Years of Experience</label> <br> <input id=”years” type=”number” step=”1”> </form> |
Tag/Attribute Name | Actual Formatted Tag | Description | Code |
---|---|---|---|
input type="checkbox" | <input type="checkbox"> | To present multiple options that allow users to select any number of given options. | <form> <p>Choose your pizza toppings</p> <br> <label for="cheese">Extra Cheese </label> <input id="cheese" name"topping type="checkbox" value="cheese"> <br> <label for="pepperoni">Pepperoni </label> <input id="pepperoni" name"topping type="checkbox" value="pepperoni"> <br> <label for="anchovy">Anchovy </label> <input id="anchovy" name"topping type="checkbox" value="anchovy"> <br> </form> |
Tag/Attribute Name | Actual Formatted Tag | Description | Code |
---|---|---|---|
input type="radio" | <input type="radio"> | To present multiple options that allow users to select only one option. | <form> <p>Are you a night owl? </p> <input type="radio" id="yes" name="answer" value="Yes"> <label for="Yes">Yes, I am. </label> <br> <input type="radio" id="no" name="answer" value="No"> <br> <label for="No">No, I'm not. </label> </form> |
Tag/Attribute Name | Actual Formatted Tag | Description | Code |
---|---|---|---|
option value | <option value="info">info</option> | To allow users to choose one option from an organized list. | <form> <label for="animal">What animal do you like? </label> <select id="animal" name="animal"> <option value="dog">Dog</option> <br> <option value="cat">Cat</option> <br> <option value="rabbit">Rabbit</option> <option value="fish">Fish</option> <option value="hamster">Hamster</option> </select> </form> |
Tag/Attribute Name | Actual Formatted Tag | Description | Code |
---|---|---|---|
datalist | <datalist id ="info"> <option value="info"></option> </datalist> |
To allow users to type in the input field to search for a particular. And if there's not option match, the user can still use what they typed in | <form> <label for="city">Ideal City to Visit? </label> <input type="text" list="cities" id="city" name="city"> <datalist id="cities"> <option value ="New York City"></option> <option value ="Tokyo"></option> <option value ="Barcelona"></option> <option value ="Melbourne"></option> <option value ="Other"></option> </datalist> </form> |
Tag/Attribute Name | Actual Formatted Tag | Description | Code |
---|---|---|---|
textarea | <textarea></textarea> | To create a bigger text field for the users to write more text. | <form> <label for=”blog”>New Blog Post:</label> <br> <text area id="blog" name="blog" rows="5" cols="30"> </textarea> </form> |
Tag/Attribute Name | Actual Formatted Tag | Description | Code |
---|---|---|---|
input type="submit" | <input type="submit"> | To collect the information that will be submitted. | <form> <input type="submit" value="Send> </form> |