Table of Contents
An HTML form is used to take input from users and send their data in backend. In this article we will try to explain the functionality of a HTML Form.
Forms in HTML
You might have filled a lot of forms in your life, offline and online. To sign up at any website, we need to fill a form with our basic details. These form data are later saved in a database table. Every time, you try to login, your data is fetched from the same table. HTML too provides tags to develop an online form.
Within form too, we need different types of controls like: we need to take input text for name, radio button for gender, checkboxes for subjects, calendar for date of birth, submit button etc.
Note: A form itself is never visible, it integrates multiple elements all together and performs a single action on them.
<!DOCTYPE html> <body> <h2>Example of a Form</h2> <form action="/action_page.php"> <div> <label>Name:</label><br> <input type="text" placeholder="Enter your Name"> </div> <div> <label>Age:</label><br> <input type="number"> </div> <div> <label>Gender:</label><br> <input type="radio" name="gender" value="male" checked>Male<br> <input type="radio" name="gender" value="female" checked>Female<br> </div> <br> <div> <input type="submit" value="Submit"> </div> </form> </body> </html>