WEB-DEVELOPMENT-APPLICATIONS practice question 15 of 25

What does a form field default to if the type attribute is omitted from a form?

Full set: 131 questions
Answer options
A: Date
B: Text Correct answer
C: Range
D: number
Correct Answer:
B. Text
Explanation

According to the HTML specification, if the type attribute is omitted from an element, its default state is "text". This means the browser will render a single-line plain text input field. This behavior ensures backward compatibility and provides a sensible default for form controls when a specific type is not declared. The same default applies if the type attribute is given an unknown or invalid value.

Why Incorrect

A. A date picker is rendered only when the type attribute is explicitly set to "date".
C. A slider control is rendered only when the type attribute is explicitly set to "range".
D. A numeric input field is rendered only when the type attribute is explicitly set to "number".

References

1. Mozilla Developer Network (MDN). (2023). : The Input (Form Input) element. In MDN Web Docs. Retrieved from https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input. (See the description of the type attribute).

2. World Wide Web Consortium (W3C). (2023). HTML Living Standard, Section 4.10.7.1 States of the type attribute. Retrieved from https://html.spec.whatwg.org/multipage/input.html#states-of-the-type-attribute. (The specification states, "The missing value default and the invalid value default are the Text state.").

Scroll to Top