What is the purpose of the type="text" attribute in an HTML input element?
It creates a single-line text box where users can enter any text. This is the most basic input type for general text input.
Click to reveal answer
beginner
How does type="email" improve user input compared to type="text"?
It helps browsers validate that the entered text looks like an email address (e.g., contains '@'). On mobile, it can show a keyboard optimized for email input.
Click to reveal answer
beginner
What does type="password" do in an input field?
It hides the characters typed by the user, showing dots or asterisks instead, to keep the password private on screen.
Click to reveal answer
beginner
What kind of data does type="number" accept, and how does it help users?
It accepts numeric input. Browsers often show up/down arrows to increase or decrease the number and show a numeric keypad on mobile devices.
Click to reveal answer
intermediate
Why is it important to use the correct input type for forms?
Using the right input type improves user experience by showing the right keyboard, enabling built-in validation, and making forms easier and safer to fill out.
Click to reveal answer
Which input type masks the characters typed by the user?
Aemail
Bpassword
Ctext
Dnumber
✗ Incorrect
The password input type hides the characters to keep the input private.
Which input type helps validate that the entered text is an email address?
Apassword
Btext
Cemail
Dnumber
✗ Incorrect
The email input type triggers validation for email format.
What does type="number" input typically show on mobile devices?
ANumeric keypad
BEmoji keyboard
CAlphabet keyboard
DNo keyboard
✗ Incorrect
Number input shows a numeric keypad to make entering numbers easier.
Which input type is best for general text input without restrictions?
Anumber
Bemail
Cpassword
Dtext
✗ Incorrect
Text input accepts any characters and is used for general text.
Why should you use specific input types instead of just type="text"?
ATo improve user experience and validation
BTo make the form look colorful
CTo make the form load faster
DTo prevent users from typing
✗ Incorrect
Specific input types help with validation and show the right keyboard, improving user experience.
Explain the differences and uses of the input types: text, email, password, and number.
Think about how each input type helps users enter data correctly and easily.
You got /4 concepts.
Describe why using the correct input type matters for accessibility and user experience.
Consider how different users interact with forms on various devices.
You got /4 concepts.
Practice
(1/5)
1. Which input type should you use to let users enter their email address?
easy
A. password
B. text
C. email
D. number
Solution
Step 1: Understand the purpose of input types
The email input type is designed specifically to accept email addresses and validate their format.
Step 2: Match input type to data
Since the question asks for an input type for email addresses, email is the correct choice.
Final Answer:
email -> Option C
Quick Check:
Email input type = email [OK]
Hint: Use email type for email inputs to get validation [OK]
Common Mistakes:
Using text instead of email loses validation
Choosing password hides input unnecessarily
Using number for emails is invalid
2. Which of the following is the correct syntax for a password input field in HTML?
easy
A. <input type='password'>
B. <input password>
C. <input type='pass'>
D. <input type='text-password'>
Solution
Step 1: Recall correct input type attribute
The correct attribute for password fields is type='password'.
Step 2: Check each option's syntax
Only <input type='password'> uses the correct attribute and syntax for a password input.
B. The min and max attributes are invalid on number inputs
C. The placeholder attribute is not allowed on email inputs
D. The type attribute is missing on the password input
Solution
Step 1: Review the required attribute usage
The required attribute is a boolean attribute and should not have a value like 'false'. It is either present or absent.
Step 2: Check other attributes
min and max are valid for number inputs, placeholder is valid for email, and type='password' is present.
Final Answer:
The required attribute cannot have a value -> Option A
Quick Check:
Boolean attributes have no value = The required attribute cannot have a value [OK]
Hint: Boolean attributes like required have no value [OK]
Common Mistakes:
Setting required='false' instead of removing attribute
Thinking min/max are invalid on number inputs
Confusing placeholder usage on email inputs
5. You want to create a form input that: - Accepts only numbers between 1 and 10 - Shows a placeholder "Enter a number" - Is required to submit the form Which is the correct HTML code?
hard
A. <input type='text' min='1' max='10' placeholder='Enter a number' required>
B. <input type='number' placeholder='Enter a number'>
C. <input type='number' min='1' max='10' placeholder='Enter a number' required='false'>
D. <input type='number' min='1' max='10' placeholder='Enter a number' required>
Solution
Step 1: Choose input type for numbers
Use type='number' to accept only numeric input.
Step 2: Set min, max, placeholder, and required correctly
Set min='1' and max='10' to limit range, add placeholder text, and use required as a boolean attribute without value.
Step 3: Verify options
<input type='number' min='1' max='10' placeholder='Enter a number' required> matches all requirements correctly. The version using type='text' allows non-numeric input, the one with required='false' misuses the required attribute, and the simplest version lacks range limits and the required attribute.
Final Answer:
<input type='number' min='1' max='10' placeholder='Enter a number' required> -> Option D
Quick Check:
Number input with min, max, placeholder, required = <input type='number' min='1' max='10' placeholder='Enter a number' required> [OK]
Hint: Use type='number' with min, max, and required (no value) [OK]
Common Mistakes:
Using type='text' for numbers
Setting required='false' instead of removing attribute
Omitting min and max for number limits
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.