html forms mcq with answers improve your preparation
HTML Forms are a very important topic in HTML. They are used to collect data from users. By taking this MCQ test, you can improve your understanding of the HTML Forms topic. In this test
Q1. Which of the following is NOT an HTML form attribute?
label is not an HTML form attribute. It is an HTML tag used to provide a label or name for an input field.
Q2. In the following code <input type='text'>, identify the attribute.
In this code, 'type' is an attribute, 'input' is the tag, and 'text' is the value of the attribute.
Q3. What is the use of the 'required' attribute?
The required attribute makes a field mandatory. The user must fill the field before submitting the form.
Q4. Which tag is used when we want to take a large amount of text input from the user?
When we need to take a large amount of text from the user, we use the <textarea> tag in HTML forms.
Q5. Which tag is used to create a dropdown list in an HTML form?
In HTML forms, the <select> tag is used to create a dropdown list and the <option> tag is used to define the options inside it.
Q6. Choose the correct code to take a telephone number from the user.
To take a telephone number from the user, we use the value 'tel' in the type attribute. It often opens a numeric keypad on mobile devices.
Q7. Which code allows a user to choose a color in an HTML form?
When we want to allow the user to choose a color, we use the value 'color' in the type attribute. This displays a color picker for the user.
Q8. What will be the output of the code <input type='text' maxlength='20'> ?
The maxlength attribute defines the maximum number of characters allowed in the input field. In this case, the user can enter up to 20 characters only.
Q9. Which attribute is used in a form to specify where the data should be sent?
The action attribute is used to specify the URL or location where the form data will be sent after submission.
Q10. Which of the following tags is NOT used to take input from the user?
The <p> tag is used to write a paragraph in HTML and is not used to take input from the user.