Details for a topic

HTML forms

A HTML form is a section of a document containing normal content, markup, special elements called controls (checkboxes, dropdowns, radio buttons, etc...) and labels on those controls.

Users generally complete a form by modifying its controls or entering text in the data fields.

All cards

How to open and close a HTML form ?

open <html>

close </html>


How to subdivise a form in sections?

<fieldset>


What are the 2 required attributes within a <form> tag?

"action" = defines the form action when submitted

"method" = defines the method "POST" or "GET" used when the form is submitted


What is the most secured method to submit a form?

The "POST" method hides datas in the adress bar (it is more secured than the "GET" method)


How to insert data fields within a form?

with the tag <input>


How to label a <fieldset> tag?

<legend>


What is the only required for an <input> field to submit the data?

the "name" attribute

ex : <input type="text" name="firstname">


How to do a linebreak ?

with the tag <br>


How to create a text data field ?

<input type="text" name="firstname" />


Which tag is used to submit a form?

<input type="submit" />


What is the role of the tag <input type="radio" /> ?

Create a question for the user with one and only one possible answer.

ex: true or false


How to make a dropdown list?

<select>


What is the role of the <textarea></textarea> tag?

Create a multiline text datafield


Which tag do you use to create a clickable button?

<button type="button"> Click here </button>


How to insert entries in a <select> dropdown list?

<option>


Why would you use the <optgroup> tag?

Group similar options in a dropdown list


What attribute forces the user to fulfill a datafield for the form to be submitted ?

<input type="text" name="firstname" required />


what is the role of the readonly attribute in an <input>?

the field can only be read, not modified


How to limit the <input>'s length ?

with the maxlength attribute


How to direct the user about what data he should enter in a precise field?

with the placeholder attribute

ex: <input type="text" name="firstname" placeholder="Firstname" />