HTML Questions and Answers Part-18

1. 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

Answer: b
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.

2. month attribute defines ___________
a) the only month
b) month and year
c) date
d) date and time

Answer: b
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.

3. week attribute defines ____________
a) week
b) year
c) week and year
d) week, month and year

Answer: c
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.

4. tel attribute is supported by the _________ browser.
a) Chrome
b) Safari
c) Opera
d) Internet Explorer

Answer: b
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.

5. Which attribute is not used on new forms?
a) size
b) text
c) name
d) maxlength

Answer: a
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”>

6. Which of the following is not used with password attribute?
a) name
b) size
c) maxlength
d) min

Answer: d
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.

7. Which element is used to create multi-line text input?
a) text
b) textarea
c) submit
d) radio button

Answer: b
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.

8. Which attribute is not used for the radio type?
a) name
b) value
c) checked
d) selected

Answer: d
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.

9. Which attribute is used with <select> element?
a) multiple
b) selected
c) name
d) value

Answer: a
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.

10. Before HTML5 where data had to be stored?
a) cookies
b) browser
c) only in Internet Explorer
d) only in Chrome

Answer: a
Explanation: When HTML5 was not introduced application data had to store in cookies when server requested for it. Web storage was secure then as well as large data could be stored even it does not affect performance. After coming of HTML5 web applications can store data within the browser that the user is using.