QCM : Mastering HTML Forms and Input Elements — 10 questions

Questions et réponses du QCM

1. What is the primary purpose of the `<form>` tag in HTML?

To display static text on a webpage
To create a container for user inputs and define how data is sent to the server
To link to external stylesheets
To embed images within a webpage

To create a container for user inputs and define how data is sent to the server

Explication

The `<form>` tag in HTML is used to create a container for user input elements and to specify how the data should be sent to the server, using attributes like `action` and `method`. It does not display static text, embed images, or link stylesheets.

2. What is the primary purpose of the `<form>` tag in HTML?

It defines a section of an HTML document for styling.
It encloses user input elements and controls data submission.
It creates a navigational menu for the webpage.
It is used to embed images within a webpage.

It encloses user input elements and controls data submission.

Explication

The `<form>` tag is used to group input elements and handle data submission to a server, which is essential for interactive forms.

3. What is the correct format for a date input (`<input type='date'>`) in HTML5?

MM/DD/YYYY
YYYY-MM-DD
DD-MM-YYYY
YYYY/MM/DD

YYYY-MM-DD

Explication

The correct format for a date input in HTML5 (`<input type='date'>`) is `YYYY-MM-DD`, following the RFC3339 format. The other formats are not valid for this input type.

4. Which attribute in the `<form>` tag specifies the URL of the server script that will process the form data?

method
action
enctype
target

action

Explication

The `action` attribute specifies the URL where the form data will be sent for processing.

5. Which attribute of the `<input>` element specifies the URL of the server-side script that processes the form data?

`method`
`href`
`src`
`action`

`action`

Explication

The `action` attribute of the `<form>` tag (not `<input>`) specifies the URL of the server-side script that will process the submitted form data. The `method` attribute determines how data is sent, `src` is used for images, and `href` is used for links.

6. What data encoding method is used when submitting form data, and how are spaces represented?

Base64 encoding; spaces as underscores.
URL-encoding; spaces as `+` or `%20`.
Binary encoding; spaces as `-`.
Hex encoding; spaces as `%20` only.

URL-encoding; spaces as `+` or `%20`.

Explication

Form data is URL-encoded, meaning unsafe characters are replaced with `%xx` codes, and spaces are encoded as `+` or `%20`.

7. Which input type is introduced in HTML5 to allow users to select colors?

type='color'
type='hex'
type='palette'
type='background'

type='color'

Explication

HTML5 introduced `type='color'` for color pickers, providing a user-friendly interface for selecting colors.

8. What is the typical format required for `<input type='date'>` and `<input type='time'>`?

Localized date and time strings.
RFC3339 formats like `YYYY-MM-DD` for date and `HH:MM` for time.
UNIX timestamp numerals.
ISO 8601 with timezone offsets.

RFC3339 formats like `YYYY-MM-DD` for date and `HH:MM` for time.

Explication

Date and time inputs require specific versions of the RFC3339 format, such as `YYYY-MM-DD` for dates and `HH:MM` for times, ensuring proper validation.

9. How do you create a dropdown menu with multiple options and include a default selected choice?

Use `<select>` with `<option>`; set `selected` attribute on desired option.
Use `<dropdown>` tag with `<option>`; set `default` attribute.
Use `<listbox>` with `<option>`; set `preferred` attribute.
Use `<menu>` with `<option>`; set `default` class.

Use `<select>` with `<option>`; set `selected` attribute on desired option.

Explication

A `<select>` element contains `<option>` elements, and you can specify the default selection by adding the `selected` attribute to an `<option>`.

10. What attribute of `<input type='radio'>` ensures only one option can be selected within a group?

name
type
value
id

name

Explication

All `<input type='radio'>` elements sharing the same `name` attribute form a group where only one can be selected at a time.

Révisez avec les flashcards

Mémorisez les réponses avec 10 flashcards sur Mastering HTML Forms and Input Elements.

HTML form — purpose?

Collects and sends user data to server

`<form>` — role?

Container for inputs, handles submission

`method` attribute — options?

POST or GET

Voir les flashcards →

Approfondir avec la fiche

Consultez la fiche de révision complète sur Mastering HTML Forms and Input Elements.

Voir la fiche →

Cours similaires

Crée tes propres QCM

Importe ton cours et l'IA génère des QCM avec corrections en 30 secondes.

Générateur de QCM