HTML forms

Página 9

Forms are one of the most important parts of an HTML page. They allow users to interact with the page and send information to the server. In HTML, forms are created using the <form> tag.

The <form> has several attributes such as action, method and enctype. The action attribute specifies where the form data will be sent. The method attribute specifies how the data will be sent, usually by GET or POST. And the enctype attribute specifies how the form data will be encoded for submission.

Inside the <form> tag are various form elements such as <input>, <textarea>, <select> and <button>. The <input> is the most common and is used to collect user information. It has several types such as text, password, checkbox, radio, file and submit.

The text type is used to collect plain text information, while the password type is used to collect passwords. The checkbox type is used to collect boolean information such as "yes" or "no". The radio type is used to gather unique information such as the user's gender. The file type is used to collect user-uploaded files. And the submit type is used to submit the form to the server.

The <textarea> is used to collect longer text information such as comments or descriptions. It has a large text area for the user to write. The <select> is used to collect information from a drop-down list. The user can select an option from the list. And the <button> is used to create custom buttons on the form.

In addition to form elements, there are also form attributes. The name attribute is used to identify the form element on the server. The value attribute is used to set the element's default value. And the required attribute is used to make an element mandatory.

Finally, it's important to remember that forms must be validated both on the client side and on the server side. Client-side validation is done using JavaScript to verify that the data is in the correct format. Server-side validation is done on the server to ensure that data sent by the user is secure and in the correct format.

In summary, forms are a fundamental part of HTML and allow users to interact with the page and submit information to the server. They are created using the <form> and have various elements and attributes to collect user information. It is important to validate forms on both the client side and the server side to ensure security and data integrity.

Now answer the exercise about the content:

_What is the attribute that specifies where the form data will be sent?

You are right! Congratulations, now go to the next page

You missed! Try again.

Next page of the Free Ebook:

10Audio and video HTML elements

Earn your Certificate for this Course for Free! by downloading the Cursa app and reading the ebook there. Available on Google Play or App Store!

Get it on Google Play Get it on App Store

+ 6.5 million
students

Free and Valid
Certificate with QR Code

48 thousand free
exercises

4.8/5 rating in
app stores

Free courses in
video, audio and text