Very Short Question and Answers - Input Elements
Ans:
An input element is a building block of HTML forms that allows users to enter data or make choices on a webpage.
Ans:
The 'type' attribute is used to specify the kind of input control in the <input> tag.
Ans:
The two input types are 'text' and 'password'.
Ans:
Checkboxes allow multiple selections, while radio buttons allow only one choice in a group.
Ans:
<input type="text" name="username" />
Ans:
'placeholder' shows hint text inside the textbox, while 'maxlength' limits the number of characters the user can enter.
Ans:
By using the 'value' attribute, e.g.,
<input type="text" value="default text">
Ans:
By adding the 'checked' attribute, e.g.,
<input type="checkbox" checked />
Ans:
So that only one option in that group can be selected at a time.
Ans:
<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> Female
Ans:
A password field hides the entered characters using dots or stars, preventing others from seeing what is entered.
Ans:
The 'checkbox' input type.
Ans:
<input type="text" maxlength="10">
Ans:
It displays a hint inside the textbox before the user enters any data.
Ans:
The 'value' attribute specifies the data sent to the server if the checkbox is checked.
Ans:
'submit' sends the form data to the server, while 'reset' clears all the inputs in the form.
Ans:
By using <input type="password" name="userpwd">
Ans:
Add the 'checked' attribute to the 'Reading' checkbox input.
Ans:
Because it identifies the data and is needed to send the input information to the server.
Ans:
Textbox: for single-line text input; Checkbox: for multiple selections; Radio button: for one choice among many; Password: for hidden/confidential text input.