HTML Forms Tutorial
HTML Forms allow users to enter and submit data. They are used everywhere—login forms, signup forms, search boxes, feedback forms, etc. In this complete tutorial, you will learn all form elements with examples and demos.
1. What is an HTML Form?
A form collects user input using different form elements like text fields, checkboxes, radio buttons, buttons, and more.
<form>
Form elements go here...
</form>
2. Basic Form Structure
<form action="#" method="post">
<input type="text" placeholder="Enter name">
<button>Submit</button>
</form>
Attributes:
- action → URL where form data is sent
- method="POST" → Secure data sending
- method="GET" → Data shows in URL
3. Text Input Field
<input type="text" placeholder="Your Name">
4. Email Input
<input type="email" placeholder="Enter Email">
5. Password Field
<input type="password" placeholder="Password">
6. Textarea (Multi-line Text)
<textarea rows="4" placeholder="Your message"></textarea>
7. Dropdown / Select
<select>
<option>Select a Country</option>
<option>India</option>
<option>USA</option>
<option>UK</option>
</select>
8. Radio Buttons
Used when the user must select only one option.
<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> Female
Male
Female
9. Checkboxes
<input type="checkbox"> Subscribe to newsletter
Subscribe to newsletter
10. File Upload Field
<input type="file">
11. Date, Time & Number Inputs
<input type="date">
<input type="time">
<input type="number" min="1" max="100">
12. Submit & Reset Buttons
<button type="submit">Submit</button>
<button type="reset">Reset</button>
13. Required Attribute
Adds validation so the field cannot be blank.
<input type="email" required>
14. Complete Form Example
<form action="#" method="post">
<input type="text" placeholder="Full Name" required>
<input type="email" placeholder="Email" required>
<input type="password" placeholder="Password" required>
<textarea placeholder="Your message"></textarea>
<button type="submit">Send</button>
</form>
Conclusion
HTML Forms are essential for collecting user input. You learned all input types, buttons, labels, dropdowns, validation, and a complete example. In the next tutorial, we will learn:
➡ HTML Tables Tutorial
Type: "Next Article: HTML Tables Tutorial" to continue.

Comments
Post a Comment