Very Short Question and Answers - Buttons and TextArea
Ans:
Buttons can be created using the <input> tag (with types 'submit', 'reset', or 'button') or the <button> tag.
Ans:
A 'submit' button sends form data to the server, while a 'reset' button clears all form fields and restores their default values.
Ans:
<button onclick="alert('Welcome!')">
Click Here
</button>
Ans:
The 'disabled' attribute makes the button inactive so users cannot click or interact with it.
Ans:
The 'value' attribute specifies the text displayed on the button.
Ans:
The <textarea> tag is used with attributes like 'rows', 'cols', and 'name' to create a multi-line text field.
Ans:
<input type="text"> creates a single-line text field, while <textarea> allows users to enter multi-line (long) text.
Ans:
By using the 'placeholder' attribute within the <textarea> tag.
Ans:
It makes the textarea non-editable; users can view the content but cannot change it.
Ans:
<textarea rows="5" cols="40"></textarea>
Ans:
The 'onclick' attribute triggers JavaScript code when the button is clicked.
Ans:
When collecting user feedback or when entering addresses that require more than one line.
Ans:
The <button> tag can hold both text and other elements like images (such as <img>).
Ans:
The 'maxlength' attribute limits the maximum number of characters that can be entered in the textarea.
Ans:
I will use the <textarea> tag because it allows users to enter multiple lines of text, suitable for long answers.
Ans:
<input type="button" name="greetBtn" value="Say Hi">
Ans:
'rows' specifies the number of visible lines, and 'cols' specifies the width (number of characters per line) of the textarea.
Ans:
Clicking the 'reset' button will clear the contents of the <textarea> and restore its default value.
Ans:
Use
<textarea rows="x" cols="y" readonly>Message</textarea>
to create a non-editable, multi-line message.
Ans:
Common attributes are: 'type', 'disabled', and 'onclick'.