oldoc63 / learningHTML

Learning HTML with Codecademy and GitHub
0 stars 0 forks source link

How a Form Works #6

Closed oldoc63 closed 3 years ago

oldoc63 commented 3 years ago

We can think of the internet as a network of computers which send and receive information. Computers need an HTTP request to know how to communicate. The HTTP request instructs the receiving computer how to handle the incoming information. More information can be found in our article about HTTP requests.

The

element is a great tool for collecting information, but then we need to send that information somewhere else for processing. We need to supply the element with both the location of where the ‘s information goes and what HTTP request to make. Take a look at the sample below:

In the above example, we’ve created the skeleton for a

that will send information to example.html as a POST request:

The action attribute determines where the information is sent.
The method attribute is assigned a HTTP verb that is included in the HTTP request.

Note: HTTP verbs like POST do not need to be capitalized for the request to work, but it’s done so out of convention. In the example above we could have written method="post" and it would still work.

The element can also contain child elements. For instance, it would be helpful to provide a header so that users know what this is about. We could also add a paragraph to provide even more detail. Let’s see an example of this in code:

Creating a form

Looks like you want to learn how to create an HTML form. Well, the best way to learn is to play around with it.

The example above doesn’t collect any user input, but we’ll do that in the next exercise. For now, let’s practice making the foundation of an HTML

!