Category: html_css
HTML forms
Published on 23 Jun 2026
Explanation
HTML forms are used to collect
user input and send data to
a server. The <form> element acts
as a container for various input
fields.
Code:
<form>
<input type="text"
placeholder="Enter your name">
<button type="submit">Submit</button>
</form>
Explanation
The text input type allows users
to enter single-line text such as
names, cities, or usernames.
Code:
<input type="text" name="username" placeholder="Enter username">
Explanation
HTML provides specialized input types like
email, password, and number that help
validate user input and improve user
experience.
Code:
<input type="email" placeholder="Enter email"> <input type="password" placeholder="Enter password"> <input type="number" placeholder="Enter age">
Explanation
Radio buttons and checkboxes allow users
to select options. Radio buttons permit
only one choice, while checkboxes allow
multiple selections.
Code:
<input type="radio" name="gender"> Male <input type="radio" name="gender"> Female <br> <input type="checkbox"> Java <input type="checkbox"> React
Explanation
Textarea and select elements are used
for multi-line input and
dropdown selections,
making forms more interactive
and user-friendly.
Code:
<textarea placeholder="Enter your feedback">