• Skip to main content
  • Select language
  • Skip to search
MDN Web Docs
  • Technologies
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs / DOM
    • WebExtensions
    • MathML
  • References & Guides
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
Learn web development
  1. MDN
  2. Learn web development
  3. HTML
  4. Forms and buttons
  5. Form and button basics

Form and button basics

In This Article
  1. Why do we have forms?
  2. A basic form
  3. Where does the data go when a form is submitted?
  4. Providing choices in forms
  5. Summary of article

Draft
This page is not complete.

Overview: Forms and buttons Next

 

In this article we'll take you through the basics of HTML forms, including their purpose, basic features, and common form controls. We'll also have a look at HTML buttons and how they can be used.

Prerequisites: Familiarity with HTML fundamentals (as covered in Getting started with HTML.)
Objective: To become familiar with the purpose and basic features of HTML forms, and be able to write your own simple forms.

Why do we have forms?

HTML forms for collecting user data, and sending them to a server for storage (e.g. in database)

analogous to paper and pen forms you fill in for some doctors and government departments

A basic form

<form>, cover basic attributes.

Briefly say that form controls are generally structured using containers like divs and lists, as well as specialised items like fieldsets. But we'll cover those in a different article.

Show example

Make sure the basic inputs are covered:

input type=text

input type=submit

textareas

Where does the data go when a form is submitted?

Talk about servers receiving requests

depending on form method, data will be sent as get parameters or post data (main options)

the action attribute specifies what server-side file the data is sent to for processing. 

at this point the server-side code will do something like put the data in a database.

Providing choices in forms

radio buttons

checkboxes

select elements

show an example of each.

Summary of article

Document Tags and Contributors

Tags: 
  • Article
  • Beginner
  • Buttons
  • Controls
  • Forms
  • HTML
  • Learn
 Last updated by: chrisdavidmills, Sep 30, 2016, 12:12:16 PM
See also
  1. Complete beginners start here!
  2. Getting started with the Web
    1. Getting started with the Web overview
    2. Installing basic software
    3. What will your website look like?
    4. Dealing with files
    5. HTML basics
    6. CSS basics
    7. JavaScript basics
    8. Publishing your website
    9. How the Web works
  3. HTML — Structuring the Web
  4. Introduction to HTML
    1. Introduction to HTML overview
    2. Getting started with HTML
    3. What's in the head? Metadata in HTML
    4. HTML text fundamentals
    5. Creating hyperlinks
    6. Advanced text formatting
    7. Document and website structure
    8. Debugging HTML
    9. Assessment: Marking up a letter
    10. Assessment: Structuring a page of content
  5. Multimedia and embedding
    1. Multimedia and embedding overview
    2. Images in HTML
    3. Video and audio content
    4. From object to iframe — other embedding technologies
    5. Adding vector graphics to the Web
    6. Responsive images
    7. Assessment: Mozilla splash page
  6. CSS — Styling the Web
  7. Introduction to CSS
    1. Introduction to CSS overview
    2. How CSS works
    3. CSS syntax
    4. Selectors introduction
    5. Simple selectors
    6. Attribute selectors
    7. Pseudo-classes and pseudo-elements
    8. Combinators and multiple selectors
    9. CSS values and units
    10. Cascade and inheritance
    11. The box model
    12. Debugging CSS
    13. Assessment: Fundamental CSS comprehension
  8. Styling text
    1. Styling text overview
    2. Fundamental text and font styling
    3. Styling lists
    4. Styling links
    5. Web fonts
    6. Assessment: Typesetting a community school homepage
  9. Styling boxes
    1. Styling boxes overview
    2. Box model recap
    3. Backgrounds
    4. Borders
    5. Styling tables
    6. Advanced box effects
    7. Assessment: Creating fancy letterheaded paper
    8. Assessment: A cool-looking box
  10. CSS layout
    1. CSS layout overview
    2. Floats
    3. Positioning
    4. Practical positioning examples
    5. Flexbox
    6. Grids
  11. JavaScript — Dynamic client-side scripting
  12. JavaScript first steps
    1. JavaScript first steps overview
    2. What is JavaScript?
    3. A first splash into JavaScript
    4. What went wrong? Troubleshooting JavaScript
    5. Storing the information you need — Variables
    6. Basic in JavaScript — Numbers and operators
    7. Handling text — Strings in JavaScript
    8. Useful string methods
    9. Arrays
    10. Assessment: Silly story generator
  13. JavaScript building blocks
    1. JavaScript building blocks overview
    2. Making decisions in your code — Conditionals
    3. Looping code
    4. Functions — Reusable blocks of code
    5. Build your own function
    6. Function return values
    7. Introduction to events
    8. Assessment: Image gallery
  14. Introducing JavaScript objects
    1. Introducing JavaScript objects overview
    2. Object basics
    3. Object-oriented JavaScript for beginners
    4. Object prototypes
    5. Inheritance in JavaScript
    6. Working with JSON data
    7. Object building practise
    8. Assessment: Adding features to our bouncing balls demo
  15. Further resources
  16. Advanced learning material
    1. WebGL: Graphics processing
  17. Common questions
    1. HTML questions
    2. CSS questions
    3. How the Web works
    4. Tools and setup
    5. Design and accessibility
  18. How to contribute