HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
  • Insights
  • Verify Certificate
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials

HTML5andCSS3.org helps developers learn modern frontend skills with practical tutorials, production-ready snippets, and fast web tools built for everyday coding.

Quick Links

  • About Us
  • Contact Us
  • Privacy Policy
  • Copyright
  • Disclaimer

Top Tools

  • Try It Editor
  • JSON Formatter
  • CSS Minifier
  • HTML Minifier
  • Base64 Encoder / Decoder

Contact

  • business@html5andcss3.org
Newsletter

Learn at your own pace, practice with useful tools, and build websites you're proud of.

© 2011-2026 html5andcss3.org. All rights reserved.

How to Use

HTML Tutorial

HTML Basics

Introduction to HTMLHTML EditorsHTML StructureHTML Elements & AttributesHTML HeadingsHTML ParagraphsHTML FormattingHTML CommentsHTML Styles

HTML Text and Links

HTML Text FormattingHTML Quotations & CitationsHTML LinksHTML Email Links

HTML Lists and Tables

HTML ListsHTML TablesTable Styling & Borders

HTML Images and Media

HTML ImagesHTML Picture ElementHTML AudioHTML VideoHTML Embed & Object

HTML Forms

HTML Forms OverviewHTML Form ElementsHTML Input TypesHTML Input AttributesHTML Form AttributesHTML Form Validation

HTML Layout

HTML Block vs Inline ElementsHTML Div & SpanHTML Semantic Layout TagsHTML Iframes

Advanced HTML

HTML Entities & SymbolsHTML EmojisHTML Head Element TagsHTML Meta Tags for SEOHTML Responsive Design

HTML References

HTML5 New TagsDeprecated TagsHTML Global AttributesEvent AttributesComplete HTML Tag ListComplete HTML5 ElementsHTML Tutorial PDF
  1. Home
  2. /
  3. Tutorials
  4. /
  5. HTML Tutorial
  6. /
  7. HTML Form Elements

HTML Forms

HTML Form Elements

HTML form elements are the building blocks that make up a form. These elements allow users to interact with a webpage - typing text, selecting options, uploading files, and submitting data. Each element serves a specific purpose to collect the right type of information.

Common Form Elements

ElementDescription
<input>Used to get user input in various formats (text, password, email, etc.).
<label>Defines a text label for form controls to improve accessibility.
<textarea>Creates a multi-line text field for long input such as comments.
<select>Defines a dropdown list of options.
<option>Defines each selectable item in a dropdown.
<button>Adds clickable buttons (submit, reset, or custom actions).
<fieldset>Groups related form controls together.
<legend>Provides a caption or title for a fieldset.
<datalist>Offers pre-defined suggestions while typing in an input.
<output>Displays the result of a calculation or script.
<optgroup>Groups related options within a <select> dropdown.

Basic Example

html

<form action="/samples/form_processor.php" method="post">
  <label for="name">Full Name:</label>
  <input type="text" id="name" name="fullname"><br><br>

  <label for="email">Email:</label>
  <input type="email" id="email" name="email"><br><br>

  <label for="message">Message:</label><br>
  <textarea id="message" name="message" rows="4" cols="30"></textarea><br><br>

  <label for="country">Select Country:</label>
  <select id="country" name="country">
    <option value="india">India</option>
    <option value="usa">USA</option>
    <option value="uk">UK</option>
  </select><br><br>

  <button type="submit">Submit</button>
</form>

Explanation of Key Elements

  • <input> - Most commonly used element; supports multiple types like text, password, checkbox, radio, and file.
  • <label> - Clicking the label focuses the input field it’s linked to via the for attribute.
  • <textarea> - Allows users to write long text.
  • <select> and <option> - Used for dropdown lists.
  • <button> - More flexible than <input type="submit">; can contain icons or text.
  • <fieldset> & <legend> - Visually group related form fields.
  • <datalist> - Adds auto-complete suggestions when typing.

Example with <datalist> and <output>

Form Example

html

<form oninput="result.value=parseInt(a.value)+parseInt(b.value)">
  <label for="browser">Choose your browser:</label>
  <input list="browsers" id="browser" name="browser">
  <datalist id="browsers">
    <option value="Chrome">
    <option value="Firefox">
    <option value="Edge">
    <option value="Safari">
  </datalist>
  <br><br>

  <input type="number" id="a" value="5"> +
  <input type="number" id="b" value="3"> =
  <output name="result" for="a b"></output>
</form>

Keynotes

  • Each form element should have a name attribute so that its value can be sent to the server.
  • Use labels for accessibility (especially for screen readers).
  • Group related fields using fieldset for clarity and organization.

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

Conclusion

HTML form elements are the core of web input collection. They define how users provide information, from a simple text field to complex dropdowns and file uploads. Understanding these elements makes it easier to design user-friendly and accessible forms.

PreviousHTML Forms OverviewNextHTML Input Types