This set of HTML Multiple Choice Questions & Answers (MCQs) focuses on “Input Types for Forms”.
1. What is the default type of ‘type’ attribute of <input> element?
d) Special Characters
Explanation: Type is the attribute that displays type of <input> elements. Its default type is text. It is supported by most of the browsers like Chrome, Internet Explorer, Firefox, Opera. Syntax is: <form action=”jump.php”> Name:<input type=”text” name=”name”> </form>
2. Which of the following is a new input attribute introduce by HTML5?
b) checkbox controls
c) submit buttons
Explanation: HTML4 has attributes with <input> elements like radio buttons, Checkbox controls, submit buttons, text input etc.
HTML5 has introduced new attributes like date, color, month, time, week, datetime-local, email, number, range, tel, url, search etc.
3. How does the color attribute work?
a) Changes color of the text
b) Changes background color
c) The color picker is defined by it
d) Changes color of the text as well as background
Explanation: color is the attribute of <input> element introduce by HTML5. It defines the color picker i.e we can select a color of our choice from the color picker. Syntax is Select the color that you want: <input type=”color” name=”favorite color”>
5. Which attribute defines the file-select field?
6. How image attribute works?
a) Sets an image background
b) Set an image as submit button
c) Set an image anywhere on the page
d) Bring default image to the page
Explanation: the image input type set an image as submit button. The syntax is <input type=”image” src=”imghj.gif” alt=”Submit”> this sets the image provided by url as the submit button. Input type image sends the X and Y coordinates of click and hence the image is activated by clicking the submit button.
7. month attribute defines ___________
a) the only month
b) month and year
d) date and time
Explanation: month and year are defined by month attribute. It does not define the time zone. The syntax is Anniversary (month and year) <input=”month” name=”anniversary month” >., date attribute defines the date, datetime-local defines date and time but no time zone.
8. week attribute defines ____________
c) week and year
d) week, month and year
Explanation: week input type defines a week and year. It does not define the time zone. Syntax is <form action=”ghu.php”> week: <input type=”week” name=”week and year”> <input type=”submit”> </form>, this gives a selection box and display a calendar like chart from where we can select a week and the year as well.
9. tel attribute is supported by the _________ browser.
d) Internet Explorer
Explanation: tel is the attribute which specifies field for telephone number. Syntax is <form action=”hkjk.php”> Telephone number: <input type=”tel” name=”usertelephone”> <br> <input type=”submit”> </form>, tel attribute is usually supported by newer versions like Safari 8.
10. Which attribute is not used on new forms?
Explanation: size attribute denotes the width of text input i.e measured by the number of characters inputted. E.g. If we input value 3 then it will create a box of width enough to display three characters. The user can enter more characters if they want. Syntax is <input type=”text” name=”firstname” size=”12” maxlength=”30”>
11. Which of the following is not used with password attribute?
Explanation: password is the attribute that creates a text box which is similar to the single line text input, but the characters are blocked out. They are hidden due to the privacy of the user. The name attribute with a password set the name of the password input, size and maxlength attributes define the size and maximum length of the text box which is to be used for the password.
12. Which element is used to create multi-line text input?
d) radio button
Explanation: For creating multi-line text input we use <textarea> element. This is not empty element i.e. it requires both opening tag and closing tag. The cols attribute defines a width of the text area. The row attributes the number of rows that the textarea can require.
13. Which attribute is not used for the radio type?
Explanation: When we want to pick one option from the given many options we use radio type. Name attribute sent the value of the option selected to the server. Value attribute indicates the value that has been sent to the server for the selected option. The checked attribute indicates that which value should be selected on the loading of the page.
14. Which attribute is used with <select> element?
Explanation: <select> element is used for drop down select box. Size attribute is used for showing more than one option. For a selection of multiple options, we use multiple attributes. It is a useful option to select multiple things at a time.
<form action=”jhi.php”> <select name=”fruits” size=”5” multiple=”multiple”>
Sanfoundry Global Education & Learning Series – HTML.
To practice all areas of HTML, here is complete set of 1000+ Multiple Choice Questions and Answers.