0
0
HTMLmarkup~20 mins

Form structure in HTML - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Form Structure Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the purpose of the
element in HTML?

Choose the best description of what the element does in an HTML page.

AIt groups input elements and sends their data to a server when submitted.
BIt styles the page layout and colors for the inputs.
CIt creates a clickable button that resets the page content.
DIt adds animations to input fields when focused.
Attempts:
2 left
💡 Hint

Think about what happens when you fill out a survey or login and press submit.

📝 Syntax
intermediate
2:00remaining
Which option correctly creates a text input inside a form?

Look at the code options below. Which one correctly creates a text input field inside a form?

HTML
<form action="/submit">
  <!-- input goes here -->
</form>
A<input type="textfield" name="username">
B<input text="username">
C<input type="text" name="username">
D<input name="username" type="input">
Attempts:
2 left
💡 Hint

The type attribute defines the kind of input. The correct value for a single line text box is 'text'.

rendering
advanced
2:00remaining
What will the browser display for this form snippet?

Given the following HTML code, what will the user see in the browser?

HTML
<form>
  <label for="email">Email:</label>
  <input id="email" type="email" name="email" required>
  <button type="submit">Send</button>
</form>
AOnly a button labeled 'Send' with no input field.
BA label 'Email:' with an email input box and a 'Send' button.
CA text input box with no label and a disabled button.
DAn error message because 'required' is not allowed on inputs.
Attempts:
2 left
💡 Hint

Labels connect to inputs by the 'for' attribute matching the input's 'id'. The 'required' attribute means the input must be filled before submitting.

selector
advanced
2:00remaining
Which CSS selector targets all input fields inside a form with class 'signup'?

Choose the CSS selector that selects every <input> element inside a <form> with class 'signup'.

Aform.signup input
Binput.signup form
C.signup > input
Dform input.signup
Attempts:
2 left
💡 Hint

Think about how to select inputs that are inside a form with a specific class.

accessibility
expert
2:00remaining
Which form structure best improves accessibility for screen readers?

Choose the form snippet that best supports screen readers by correctly associating labels with inputs.

A<label>Email<input type="email" name="email"></label>
B<input type="email" name="email"><span>Email</span>
C<input type="email" name="email" aria-label="Email">
D<label for="email">Email</label><input id="email" type="email" name="email">
Attempts:
2 left
💡 Hint

Labels should be explicitly linked to inputs using 'for' and 'id' attributes for best accessibility.