HTML5 HTML5 Forms and Input Types 1 — Questions and Answers
Question 1: Which HTML5 input type is used to let users select a date from a date picker?
- date (Correct answer)
- datetime
- calendar
- picker
Correct answer: date
The input type='date' provides a native browser date picker control for selecting year, month, and day.
Question 2: What does the 'required' attribute do on an HTML5 form input?
- Prevents form submission if the field is empty (Correct answer)
- Sets a default value
- Makes the field read-only
- Hides the field from screen readers
Correct answer: Prevents form submission if the field is empty
The required attribute specifies that an input field must be filled out before the form can be submitted.
Question 3: Which HTML5 input type is designed for entering email addresses with built-in validation?
- email (Correct answer)
- text
- url
- contact
Correct answer: email
The input type='email' validates that the value contains an @ symbol and is formatted as a valid email address.
Question 4: What is the purpose of the 'placeholder' attribute in HTML5 form inputs?
- Displays hint text inside the field that disappears when the user types (Correct answer)
- Sets the default value of the field
- Labels the field for screen readers
- Validates the input format
Correct answer: Displays hint text inside the field that disappears when the user types
The placeholder attribute shows a short hint describing the expected value inside the input field, which disappears when the user starts typing.
Question 5: Which input type renders a slider control for selecting a numeric value within a range?
- range (Correct answer)
- number
- slider
- scale
Correct answer: range
The input type='range' renders a slider control allowing the user to select a value between min and max attributes.
Question 6: The 'autocomplete' attribute on an HTML5 form field controls:
- Whether the browser can automatically fill in the field value (Correct answer)
- Spell-checking behavior
- Automatic form submission
- Input validation patterns
Correct answer: Whether the browser can automatically fill in the field value
The autocomplete attribute tells the browser whether it may store and automatically fill in field values based on previously entered data.
Which HTML5 input type is used to let users select a date from a date picker?