The <form> tag is the container for all form elements. It defines how data is sent to the server.
The <input> tag creates interactive fields. The type attribute defines its behavior. The name attribute identifies the data on the server.
min and max.for with input id.Forms collect information from users. They allow websites to log in, search, comment, and place orders.
Groups fields together for submission.
Creates input fields. Behavior changes with type (text, radio, checkbox).
Labels describe inputs. Use for with id for accessibility.
The name tells the server what the data represents.
Only one option can be selected at a time.
Users can select multiple options.
Use type="password" for hidden text entry.
Use type="number" to accept numeric values only.
Use type="date" to show a calendar picker.
More input types introduced in HTML5:
type="color" → Color pickertype="range" → Slider controltype="file" → File uploadUseful form attributes:
required → Makes input mandatoryplaceholder → Shows hint text inside the box| Tag/Attribute | Purpose |
|---|---|
| <form> | Main container for form elements |
| action | URL where data is sent |
| method | HTTP method (GET or POST) |
| <input type="text"> | Single-line text input |
| <input type="password"> | Hidden/masked text input |
| <input type="submit"> | Submit button |
| <input type="checkbox"> | Select multiple options |
| <input type="radio"> | Select only one option from a group |
| <input type="file"> | File upload |
| <input type="email"> | Email field with validation |
| <input type="number"> | Number input with min/max |
| <input type="date"> | Date picker |
| <input type="color"> | Color picker |
| <input type="range"> | Slider input |
| <label> | Describes an input field |
| <textarea> | Multi-line input field |
| <select> & <option> | Dropdown list with choices |
| <button> | Customizable button |
| name | Key to identify submitted data |
| id | Unique identifier within page |
| placeholder | Hint text inside field |
| required | Makes input mandatory |
| value | Predefined value sent with form |