Forms are an essential part of web development, allowing users to submit data. This section covers form elements, attributes, and input types, such as text, password, checkboxes, and radio buttons.
MCQs on Forms and User Input
Section 1: Form Elements
Which tag is used to create an HTML form? a) <input> b) <form> c) <button> d) <textarea>
Which element is used to define a text input field in an HTML form? a) <button> b) <input type="text"> c) <input type="password"> d) <textarea>
What is the purpose of the <textarea> element? a) To create a clickable button b) To allow multi-line text input c) To define a password field d) To create a drop-down list
Which tag is used to define a button in HTML forms? a) <input> b) <button> c) <submit> d) <form>
What is the main purpose of the <form> element in HTML? a) To create a structure for displaying data b) To gather input from users and send it to the server c) To format the content of a page d) To define metadata of a webpage
Section 2: Form Attributes
What does the action attribute of a form specify? a) The method of form submission b) The location where the form data will be sent c) The form’s title d) The input data type
Which method is commonly used for sending form data to a server in HTML? a) GET b) POST c) PUT d) DELETE
What does the enctype attribute in a form define? a) The encoding type for the form data b) The action URL for form submission c) The method of form submission d) The file types allowed in the form
What happens if the action attribute is omitted from a form? a) The form data is not submitted b) The form submits data to the same URL as the page c) The form will not display d) The form uses the POST method by default
In which scenario is the enctype attribute most useful? a) When submitting simple text data b) When uploading files via the form c) When specifying form validation d) When using the GET method
Section 3: Input Types
Which input type is used for password fields in HTML? a) <input type="text"> b) <input type="password"> c) <input type="email"> d) <input type="password-field">
Which of the following is a correct input type for a checkbox? a) <input type="radio"> b) <input type="checkbox"> c) <input type="select"> d) <input type="button">
What is the purpose of the type="submit" input in a form? a) To submit the form data to the server b) To reset the form fields c) To display a button in the form d) To allow the user to select multiple options
Which input type is used for radio buttons in HTML? a) <input type="checkbox"> b) <input type="radio"> c) <input type="button"> d) <input type="text">
What is the default input type for an <input> element without specifying a type attribute? a) Text b) Submit c) Password d) Checkbox
Section 4: Form Validation and Handling
Which attribute is used to make an HTML input field mandatory? a) required b) mandatory c) validate d) check
What is the use of the placeholder attribute in a form field? a) To display a hint inside the input field b) To show the input data c) To restrict input length d) To define the input type
Which input type is used to collect an email address? a) <input type="email"> b) <input type="url"> c) <input type="text"> d) <input type="password">
How can you define a field that allows the user to select a file for upload? a) <input type="file"> b) <input type="image"> c) <input type="select"> d) <input type="button">
Which attribute specifies the action URL of a form? a) action b) method c) target d) enctype
Section 5: Advanced Form Elements
What does the value attribute of an input element define? a) The maximum value allowed for input b) The default value or data for the input field c) The type of the input field d) The position of the input element
How do you specify multiple options for a select dropdown menu in HTML? a) <input type="dropdown"> b) <select> and <option> elements c) <input type="radio"> d) <button>
Which tag is used to group radio buttons in a form? a) <group> b) <fieldset> c) <form> d) <section>
How do you define a multi-choice dropdown list in HTML? a) <select multiple> b) <input type="dropdown"> c) <option multiple> d) <select>
Which of the following input types can accept multiple values? a) <input type="radio"> b) <input type="checkbox"> c) <input type="text"> d) <input type="submit">
Which attribute is used to define the minimum length of input in HTML? a) maxlength b) minlength c) size d) required
Which of the following is used to specify the target for form submission? a) target b) action c) method d) formaction
How do you reset all the input fields in a form? a) <input type="reset"> b) <button type="reset"> c) <input reset> d) <button reset>
What is the default method for form submission in HTML? a) POST b) GET c) PUT d) DELETE
Which input type is used for a date picker in HTML? a) <input type="date"> b) <input type="datetime"> c) <input type="text"> d) <input type="date-picker">
Answers
Qno
Answer
1
b) <form>
2
b) <input type="text">
3
b) To allow multi-line text input
4
b) <button>
5
b) To gather input from users and send it to the server
6
b) The location where the form data will be sent
7
b) POST
8
a) The encoding type for the form data
9
b) The form submits data to the same URL as the page