HTML Form Structure

Learn to build user data collection forms with the essential <form>, <label>, and <input> tags.

Building Your First Form

Forms are essential for collecting user data. Let's learn the basic building blocks: the `<form>`, `<label>`, and `<input>` tags.

The `<form>` Tag

The <form> tag is the container for different types of input elements, such as text fields, checkboxes, radio buttons, submit buttons, etc. It defines how the form data is sent.

The `<label>` Tag

The <label> tag defines a label for many form elements. It improves usability by allowing users to click on the text to focus the corresponding input field.

The `<input>` Tag

The <input> tag is the most versatile form element. It can be displayed in many ways, depending on the type attribute (e.g., text, password, checkbox, submit).

Practice Zone


Interactive Test 1: Drag & Drop

Arrastra en el orden correspondiente.


Arrastra las opciones:

</form>
<form
type="text"
for="name"
type="submit"

Completa el código:

______action='/submit' method='post'>
<label ______>Name:</label>
<input ______ id='name' name='name'>
<input ______ value='Submit'>
______

Interactive Test 2: Fill in the Blanks

Rellena los huecos en cada casilla.

<form action="/submit" method="post">
   for="name">Name:
  <input  id="name" name="name">
  <input  value="Submit">

Practice Example: Code Editor

Create a form with a text field for the name and a submit button. Remember to use the <form>, <input>, and <label> tags.

* Write the code below. Correct characters will be shown in green and incorrect ones in red.

<form action="/submit" method="post"> <label for="name">Name:</label> <input type="text" id="name" name="name"> <input type="submit" value="Submit"> </form>

Knowledge Check

Which attribute is used to specify where the data from an HTML form is sent?