Handling Form Questions with Answers

15 practice questions on Handling Form (HTML & CSS) with answers and step-by-step solutions. Try 10 samples below, then practise all 15 free in the AptiNest app.

Sample questions

Question 1Medium

What is the syntax of label tag?

  1. <label for="male">Male</label>
  2. <label ="male">Male</label>
  3. <for="male">Male</label>
  4. None of these

Answer: A. <label for="male">Male</label>

Explanation

A <label> is bound to a form control by its for attribute (matching the control's id), or by placing the control inside the <label> element.

Step-by-step solution

  1. A label is linked to a control with its for attribute.
  2. The for value matches the id of the control, here male.
  3. Option A is a label tag with the for attribute, so it is the correct answer.

Why the other options are wrong

  • B. The for attribute name is missing, so the label is not linked.
  • C. The label opening tag is missing and the for attribute has no name.
  • D. Option A is valid, so none of these is wrong.

Tip: A label's for value must match the control's id.

Question 2Medium

What is action attribute of form?

  1. Points to a file that acts as processing agent for the form data.
  2. Points to a file that acts as storing agent for the form data.
  3. Points to a file that acts as output agent for the form data.
  4. None of these.

Answer: A. Points to a file that acts as processing agent for the form data.

Explanation

The action attribute gives the file or server page that processes the form data, for example to send an email or save the data to a database. Example: <form action="../save-user-info.php">.

Step-by-step solution

  1. Action attribute tells where to send form data.
  2. It points to a file that handles the data, like saving or processing.
  3. This file acts as the processing agent for the form data.
  4. Other options mention storing or output agents, which are not correct.
  5. Correct answer is option A.

Why the other options are wrong

  • B. Stores data, but action attribute does not store.
  • C. Output agent is not the role of action attribute.

Tip: Remember: action points to a processing file, not storage or output.

Question 3Medium

Which attribute is used in label tag?

  1. While
  2. Whom
  3. For
  4. None of these

Answer: C. For

Explanation

For attribute is used by label tag which defines for whom that label is used.

Step-by-step solution

  1. Label tag uses 'for' attribute to link with input elements.
  2. 'For' specifies the ID of the element the label is associated with.
  3. This helps in accessibility and user experience.
  4. Other attributes like 'while' or 'whom' are not used here.
  5. Correct answer is 'For'.

Why the other options are wrong

  • A. While is not an attribute of label; the label tag does not use it.
  • B. Whom is not a label attribute; the tag uses for to link to an input.
  • D. None of these is wrong, because for is a valid label attribute.

Tip: Remember: 'for' links labels to inputs, not 'while' or 'whom'.

Question 4Medium

Syntax for textarea is?

  1. < textarea rows="4" cols="50"></textarea>
  2. <textarea></textarea>
  3. < rows="4" cols="50"></textarea>
  4. None of these.

Answer: A. < textarea rows="4" cols="50"></textarea>

Explanation

We can store unlimited data inside textarea, but in order to look good we have to provide external rows and columns.

Step-by-step solution

  1. A textarea is a multi-line text box and needs a closing tag.
  2. The rows and cols attributes set the visible size of the box.
  3. So the right syntax is a textarea tag with rows and cols, then its closing tag.
  4. The answer is option A.

Why the other options are wrong

  • B. This works but sets no size, and the question asks for rows and cols.
  • C. The textarea tag name is missing.
  • D. Option A is correct, so None of these is wrong.

Tip: A textarea always needs a closing tag; rows and cols set its size.

Question 5Medium

What is use of textarea tag?

  1. Single line text input
  2. Multiline text input
  3. Multi page text input
  4. None of these

Answer: B. Multiline text input

Explanation

The textarea tag is used for multiline text input, allowing users to enter multiple lines of text.

Step-by-step solution

  1. Textarea allows entering more than one line of text.
  2. It replaces the single-line input with multiple lines.
  3. Users can type several sentences or paragraphs in it.
  4. This makes it suitable for longer text entries.
  5. The correct use is multiline text input.

Why the other options are wrong

  • A. Single line text input is done using the input tag.
  • C. Multi page text input is not a standard HTML feature.

Tip: Use textarea for forms requiring paragraphs or detailed entries.

Question 6Medium

Which of the following is syntactically correct HTML code?

  1. <INPUT TYPE= "submit" VALUES = "reset, submit">
  2. <INPUT TEXT = "submit" VALUE = "reset">
  3. <INPUT TYPE = "submit" VALUE = "reset">
  4. <INPUT TYPE = "reset" TEXT = "clear">

Answer: C. <INPUT TYPE = "submit" VALUE = "reset">

Explanation

The <input> tag specifies an input field where the user can enter data.

<input> elements are used within a <form> element to declare input controls that allow users to input data.

An input field can vary in many ways, depending on the type attribute.

Step-by-step solution

  1. The input tag uses TYPE to choose the control and VALUE to set its label.
  2. Option C has TYPE = submit and VALUE = reset, both valid attributes.
  3. So option C is the syntactically correct tag, the correct answer.

Why the other options are wrong

  • A. VALUES is misspelt, and a list of two values is not valid here.
  • B. TEXT is not an input attribute; the attribute is VALUE.
  • D. TEXT is not an input attribute, so this tag is not valid.

Tip: Input tags use TYPE and VALUE; check spelling of each attribute.

Question 7Medium

Which of the following is not valid attribute of input tag?

  1. text
  2. name
  3. size
  4. maxlength

Answer: A. text

Explanation

text is not valid attribute of input tag.

attributes of input tag:-
1.name- Specifies the name of an <input> element.
2.size- Specifies the width, in characters, of an <input> element.
3.maxlength- Specifies the maximum number of characters allowed in an <input> element

Step-by-step solution

  1. The input tag has attributes such as name, size and maxlength.
  2. Name names the field, size sets its width, and maxlength limits the characters.
  3. Text is a value for the type attribute, not an attribute of its own.
  4. So the correct answer is option A, text.

Why the other options are wrong

  • B. Name is a valid input attribute.
  • C. Size is a valid input attribute that sets the width.
  • D. Maxlength is a valid input attribute that limits characters.

Tip: Text is a value of the type attribute, while name, size and maxlength are attributes.

Question 8Medium

Which of the following is not an attribute of the SELECT tag?

  1. Name
  2. Multiple
  3. Size
  4. Option.

Answer: D. Option.

Explanation

The 'option' element is used inside the 'select' tag to define individual choices, but it is not an attribute of the 'select' tag itself.

Step-by-step solution

  1. Name, Multiple and Size are all attributes of the select tag.
  2. The option element is a separate tag placed inside select to define each choice.
  3. So option D is the one that is not an attribute of select.

Why the other options are wrong

  • A. Name is a valid attribute of select.
  • B. Multiple is a valid attribute that allows more than one choice.
  • C. Size is a valid attribute that sets how many rows are visible.

Tip: An attribute belongs to one tag. A tag name used inside another tag is not an attribute of it.

Question 9Medium

what is the "name" attribute of form?

  1. The name attribute specifies the name of a form.
  2. The name attribute specifies the name of a database.
  3. The name attribute specifies the program name .
  4. None of these.

Answer: A. The name attribute specifies the name of a form.

Explanation

The name attribute is used to reference elements in a JavaScript, or to reference form data after a form is submitted.< form name="text">

Step-by-step solution

  1. The name attribute identifies the form for scripting purposes.
  2. It allows access to form data after submission.
  3. Option A directly states this function of the name attribute.
  4. Other options refer to unrelated concepts like databases or program names.
  5. Thus, the correct answer is option A.

Why the other options are wrong

  • B. The name attribute does not relate to databases.
  • C. The name attribute is not for program names.

Tip: Remember the name attribute is for identifying forms in code.

Question 10Medium

To provide a default checked box, you can use which attribute of the INPUT tag?

  1. Checkbox
  2. Check
  3. Checked
  4. Mark

Answer: C. Checked

Explanation

to provide default checkbox you can use checked attribute of input tag.

Step-by-step solution

  1. The INPUT tag has an attribute called 'checked' for default selection.
  2. Using 'checked' makes the checkbox selected by default.
  3. Other attributes like 'checkbox' or 'check' do not set default selection.
  4. The correct attribute is 'Checked'.
  5. Final answer: Checked.

Why the other options are wrong

  • A. Checkbox is an input type value, not the attribute that sets the default checked state.
  • B. Check is not a valid attribute of INPUT; the default selection uses checked instead.
  • D. Mark is not an INPUT attribute for default selection; checked is the right one.

Tip: Use 'checked' for default selected inputs.

Practise all 15 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all HTML & CSS topics · All topics