SA-21/06, C-11, Asapur, Varanasi, UP support@kamaldnp.com +91 8318013442
HTML
1. HTML Introduction: What is HTML? Learn with Examples 2. Best Free HTML Editors: Notepad to VS Code for Beginners 3. HTML Basic Structure: Doctype, Head, Body Explained 4. HTML Elements Explained: Tags, Content & Empty Elements 5. HTML Attributes List: href, src, alt, width, title & More 6. HTML Headings h1 to h6: Which Heading Tag to Use When 7. HTML Paragraphs: p Tag, br Line Breaks & pre Text 8. HTML Style Attribute: Colour, Font Size & Alignment 9. HTML Text Formatting Tags: bold, italic, mark & More 10. HTML Comments: How to Add Notes & Hide Code in HTML 11. HTML Colors: Names, HEX, RGB & HSL Colour Codes 12. HTML CSS: Inline, Internal & External Stylesheets 13. HTML Links: a Tag, href, New Tab & Email Links 14. HTML Images: img Tag, src, alt, Width & Formats 15. HTML Favicon: Create & Add a Browser Tab Icon 16. HTML Title Tag: How to Write a Good Page Title 17. HTML Tables: table, tr, th, td, colspan & rowspan 18. HTML Lists: ul, ol, dl & Nested Lists Explained 19. HTML Block vs Inline Elements: div, p, span Explained 20. HTML Div Tag: Group Content & Build Page Layouts 21. HTML Class Attribute: Style Many Elements at Once 22. HTML id Attribute: Unique IDs, Links, CSS & JavaScript 23. HTML Iframes: Embed YouTube, Maps & Pages in HTML 24. HTML JavaScript: script Tag, Clicks & First Example 25. HTML File Paths: Relative vs Absolute Paths Explained 26. HTML Head Element: title, meta, charset & viewport 27. HTML Layout: header, nav, main, footer Page Structure 28. HTML Responsive Design: Viewport, Images & Media Queries 29. Semantic HTML Tags: header, nav, main, article & footer 30. HTML Forms: input, label, select, checkbox & Submit 31. HTML Entities: & < > © with Examples 32. HTML Audio & Video Tags: controls, source & Fallback 33. HTML Accessibility: alt Text, Labels, Landmarks & ARIA 34. HTML Meta Tags & SEO: charset, viewport, OG Tags 35. HTML Quotations: blockquote, q, cite, abbr & address
Final Test — Certificate ₹10
Try this code live
Lesson 30 of 35

HTML Forms: input, label, select, checkbox & Submit

4 min read · Free · No login needed

Forms are how a website collects information: a login, a signup, a contact message, a search box, a payment. The <form> tag wraps all the fields, and when the visitor clicks submit, the browser sends the data to the server address in the form's action attribute.

Diagram — see how it fits together
Diagram: parts of an HTML form

The input types you will use most

  • text — a single line of text (name, city).
  • email — an email address; the browser checks the format for you.
  • password — hides the characters as you type.
  • number — numbers only, with up/down arrows.
  • tel — a phone number; on mobile it opens the number keyboard.
  • date — a date picker.
  • radio — pick one option from a group.
  • checkbox — pick any number of options.

Labels — never skip them

Every input needs a <label> connected with the for attribute matching the input's id: <label for="email">Email</label> <input type="email" id="email" name="email">. The label does two things: it tells the visitor what to type, and clicking it focuses the field. Without labels, a form is confusing — and screen readers cannot explain it at all.

Other form elements

<textarea> is for multi-line text (a message). <select> with <option> children is a dropdown. <button type="submit"> sends the form. The required attribute makes a field compulsory — the browser refuses to submit until it is filled.

Tip: The name attribute is what the server sees. Two fields with the same name will overwrite each other. Always give every input a name — an input without one sends nothing.

What a form is

A form is how a visitor sends information to a website — a name, an email address, a message, a search word. The <form> tag wraps the fields. When the visitor clicks the submit button, the browser collects the values and sends them to the address in the form's action attribute, using the method in its method attribute.

Form attributes

AttributeValueDescription
actiona web addressWhere the form data is sent. Required for a working form.
methodget or postget puts the data in the address bar; post hides it. Use post for anything private.
nametextA name for the form itself, used by JavaScript.

Input types

TypeValueDescription
textany textA single line of text — names, cities, subjects.
passwordany textText shown as dots, for passwords.
emailan email addressThe browser checks that it looks like an email.
numbera numberNumbers only, with up and down arrows.
datea dateShows a date picker.
checkboxon / offA tick box — several can be ticked at once.
radioone choiceA round button — only one in a group can be chosen.
submit—The button that sends the form.

A label is connected to its input with the for attribute, which must match the input's id. Clicking the label then focuses the input — a small thing that makes forms much easier to use:

<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
Note: The name attribute on an input is what gets sent to the server. An input without a name is invisible to the server — its value is never sent, even if the visitor typed in it. Every input that should send data needs a name.
Tip: Add required to fields the visitor must fill in, like name and email. The browser then stops the form and shows a message if they are left empty — no JavaScript needed.

Common mistakes

  • Skipping the <label> — a form without labels is hard to use, and screen readers cannot explain the fields.
  • Forgetting the name attribute on inputs — the server receives nothing from those fields.
  • Using method="get" for a password form — the password would appear in the address bar. Use post.
  • Using a plain button instead of type="submit" — the form will not send.

Example explained

  • <form action="/submit.php" method="post"> — wraps all the fields. action is where the data goes, and post keeps it out of the address bar.
  • <label for="name">Your Name:</label> — the label for the first field. Its for matches the input's id, so clicking the label focuses the field.
  • <input type="text" ... required> — a one-line text box for the name. required makes the browser refuse to submit until it is filled.
  • <input type="email" ...> — an email field. The browser checks the format for you before the form is sent.
  • <select> with three <option> children — a dropdown. The visitor picks one course: HTML, CSS or JavaScript.
  • <button type="submit">Submit</button> — sends the form. Without type="submit", the button would do nothing.

Example

Example
<!DOCTYPE html>
<html>
<head>
<title>Forms</title>
</head>
<body>

<form action="/submit.php" method="post">
<label for="name">Your Name:</label><br>
<input type="text" id="name" name="name" required><br><br>
<label for="email">Email:</label><br>
<input type="email" id="email" name="email" required><br><br>
<label for="course">Course:</label><br>
<select id="course" name="course">
<option value="html">HTML</option>
<option value="css">CSS</option>
<option value="js">JavaScript</option>
</select><br><br>
<button type="submit">Submit</button>
</form>

</body>
</html>

Output

Output — how it looks in the browser
Output of HTML Forms: input, label, select, checkbox & Submit

Try it yourself — live editor

Change the code below and press Run to see the result instantly. No file to save, no login needed.

Result

Frequently asked questions

The questions learners ask most about this lesson — read the question, then open it to see the answer.

1. What does a form do?

It collects information from a visitor, such as a login, signup, contact message or search, and sends it to the server address in action.

2. Why does every input need a label?

The label tells the visitor what to type and clicking it focuses the field, and without it screen readers cannot explain the form.

3. What happens if an input has no name?

The server receives nothing from that field, because name is what gets sent to the server.

Why learn this yourself — and not just ask AI?

AI can write code for you, but it cannot think for you. When you learn HTML yourself, your brain builds the real skill: you understand why a page looks the way it does, you can fix it when it breaks, and you can answer it in an exam or an interview without help. That is the skill that gets you a job — not a copied answer.

Get certified — just ₹10

Finish all 35 lessons, pass the test (80%), pay ₹10 and get your certificate.

Take the test

Prefer watching? Video courses teach the same topics step by step.

Go further with a full course

Free tutorials teach you the basics. Our paid courses add live projects, mentorship and a certificate.

Website Design Using WordPress 3 Days (Basic to Advanced)
₹199
View
AI Power Skills in 2 Days | Learn AI Text, Image, Video and Voice Tools
View
Core Python Programming – 3 Month Complete Course
₹700
View
Browse all courses
HTML — Lessons
1. HTML Introduction: What is HTML? Learn with Examples 2. Best Free HTML Editors: Notepad to VS Code for Beginners 3. HTML Basic Structure: Doctype, Head, Body Explained 4. HTML Elements Explained: Tags, Content & Empty Elements 5. HTML Attributes List: href, src, alt, width, title & More 6. HTML Headings h1 to h6: Which Heading Tag to Use When 7. HTML Paragraphs: p Tag, br Line Breaks & pre Text 8. HTML Style Attribute: Colour, Font Size & Alignment 9. HTML Text Formatting Tags: bold, italic, mark & More 10. HTML Comments: How to Add Notes & Hide Code in HTML 11. HTML Colors: Names, HEX, RGB & HSL Colour Codes 12. HTML CSS: Inline, Internal & External Stylesheets 13. HTML Links: a Tag, href, New Tab & Email Links 14. HTML Images: img Tag, src, alt, Width & Formats 15. HTML Favicon: Create & Add a Browser Tab Icon 16. HTML Title Tag: How to Write a Good Page Title 17. HTML Tables: table, tr, th, td, colspan & rowspan 18. HTML Lists: ul, ol, dl & Nested Lists Explained 19. HTML Block vs Inline Elements: div, p, span Explained 20. HTML Div Tag: Group Content & Build Page Layouts 21. HTML Class Attribute: Style Many Elements at Once 22. HTML id Attribute: Unique IDs, Links, CSS & JavaScript 23. HTML Iframes: Embed YouTube, Maps & Pages in HTML 24. HTML JavaScript: script Tag, Clicks & First Example 25. HTML File Paths: Relative vs Absolute Paths Explained 26. HTML Head Element: title, meta, charset & viewport 27. HTML Layout: header, nav, main, footer Page Structure 28. HTML Responsive Design: Viewport, Images & Media Queries 29. Semantic HTML Tags: header, nav, main, article & footer 30. HTML Forms: input, label, select, checkbox & Submit 31. HTML Entities: & < > © with Examples 32. HTML Audio & Video Tags: controls, source & Fallback 33. HTML Accessibility: alt Text, Labels, Landmarks & ARIA 34. HTML Meta Tags & SEO: charset, viewport, OG Tags 35. HTML Quotations: blockquote, q, cite, abbr & address
Final Test — Certificate ₹10

🤖 KAMALDNP AI Assistant

Ask about courses, website & more

Hi! I'm KAMALDNP AI Assistant. Ask me about our courses, website features, or anything else! 😊
Please wait 5s...
🤖 KAMALDNP Assistant ✕

Request human callback:

🔐 Login Required
✕

Please log in to download. You will stay on this page after logging in!

New here? Register now →