Mastering HTML Forms and Input Elements Practice Quiz (10 questions)

All questions and answers

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

Explanation

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 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

Explanation

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.

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

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

`action`

Explanation

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.

4. 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.

Explanation

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

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

method
action
enctype
target

action

Explanation

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

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`.

Explanation

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'

Explanation

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.

Explanation

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.

Explanation

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

Explanation

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

Study with flashcards

Lock in the answers with 10 flashcards on Mastering HTML Forms and Input Elements.

HTML form — purpose?

Collects and sends user data to server

`method` attribute — options?

POST or GET

Date input — format?

YYYY-MM-DD (RFC3339)

See the flashcards →

Read the study guide

Go over the full study guide for Mastering HTML Forms and Input Elements.

Read the study guide →

Related classes

Make your own practice quizzes

Upload your class notes and Revizly writes a practice quiz with explained answers in about a minute.

Quiz maker