What is the purpose of the <form>
element in HTML?
Answer: It is used to create a form for user input and to send data to a server.
Which attribute of the <form>
element specifies the HTTP method used to send form data?
Answer: method
GET
and POST
methods in a form?GET
: Appends form data to the URL and is visible in the address bar.POST
: Sends form data in the request body and is not visible in the URL.How do you create a text input field in a form?
Answer: Use the <input type="text">
tag.
Which attribute is used to make a form field mandatory?
Answer: required
How do you create a password input field in a form?
Answer: Use the <input type="password">
tag.
What is the purpose of the action
attribute in a <form>
element?
Answer: It specifies the URL where the form data should be sent.
How do you create a dropdown list in a form?
Answer: Use the <select>
tag with <option>
tags for each item.
Which attribute is used to group radio buttons together?
Answer: name
How do you create a checkbox in a form?
Answer: Use the <input type="checkbox">
tag.
What is the purpose of the placeholder
attribute in an input field?
Answer: It provides a hint or example text inside the input field.
How do you create a file upload field in a form?
Answer: Use the <input type="file">
tag.
What is the purpose of the accept
attribute in a file input field?
Answer: It specifies the types of files that can be uploaded.
How do you create a submit button in a form?
Answer: Use the <input type="submit">
tag.
What is the purpose of the enctype
attribute in a <form>
element?
Answer: It specifies how the form data should be encoded when submitting it to the server.
How do you create a date picker in a form?
Answer: Use the <input type="date">
tag.
What is the purpose of the pattern
attribute in an input field?
Answer: It specifies a regular expression that the input value must match.
How do you create a range slider in a form?
Answer: Use the <input type="range">
tag.
checked
and selected
attributes in a form?checked
: Used for checkboxes and radio buttons to pre-select an option.selected
: Used for dropdown lists to pre-select an option.<input type="reset">
tag.Learn the basics of HTML, including elements, attributes and forms controls.