Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

The Form Element

HTML forms are a way to get data from users. You use them on the internet all the time, often without noticing: whenever you type into a search box, log in, sign up or choose from several options, you're filling in a form.

In this lesson, we'll look at how forms are built and which elements we use to collect data. Step by step, we'll create a sign-up form for a course.

A form is created with the form element. The form collects information, but then it has to send it somewhere to be processed. That's why the form element has two attributes:

  • action: the URL the form data is sent to.
  • method: how the data is sent (the method of the HTTP request).

The two most common methods are:

  • GET (used when we leave out method): the data is added to the page address, for example /search?q=cats. That suits a search, because the address with the results can be saved or shared.
  • POST: the data is sent inside the request, not in the address. We use it, for example, for logging in and signing up, so that a password doesn't end up in the address.

For now, you don't need to know what exactly an HTTP request is.

<form action="/processing.html" method="POST">
</form>

Instructions

  1. 1

    Create a form element with the attribute action with the value /exercise.html and the attribute method with the value POST. You won't see the form yet: it stays invisible until we add inputs to it.

Back

1/11

  1. 1. The Form Element
  2. 2. Text Input
  3. 3. Input Label
  4. 4. Password Input
  5. 5. More Input Types
  6. 6. Radio Buttons and Checkboxes
  7. 7. Drop-down List
  8. 8. Longer Text
  9. 9. Form Submission
  10. 10. Required Input
  11. 11. Form Summary
Next

Try it yourself

Do this exercise right here in your browser. No account needed.