0% found this document useful (0 votes)
2 views

Revision Chapter 10 (Computer)

Chapter 10 covers the creation of forms in HTML, detailing various input elements such as text fields, checkboxes, radio buttons, password fields, dropdowns, and buttons. It explains how to use the <form> tag and the importance of attributes like type, name, value, size, and maxlength for input elements. Additionally, it highlights best practices for accessibility and provides answers to common questions regarding form controls.

Uploaded by

Aviral Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Revision Chapter 10 (Computer)

Chapter 10 covers the creation of forms in HTML, detailing various input elements such as text fields, checkboxes, radio buttons, password fields, dropdowns, and buttons. It explains how to use the <form> tag and the importance of attributes like type, name, value, size, and maxlength for input elements. Additionally, it highlights best practices for accessibility and provides answers to common questions regarding form controls.

Uploaded by

Aviral Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Revision Chapter 10: Form in HTML

Creating a form:
In HTML, a “form” is a section of a webpage that allows users
to input data through various interactive elements like text
fields, checkboxes, radio buttons, and dropdown menus,
which can then be submitted to a server for processing;
essentially, it’s a way to collect user information on a
website, like a digital questionnaire, using the <form> tag
and various input elements within it.

Creating text control:


The <input type=”text”> control defines a single-line text
input. We can use the HTML <textarea> tag to create multi-
line input control if the user input is longer than a single line.

Adding Checkbox:
The <input type=”checkbox”> defines a checkbox. The
checkbox is shown as a square box that is ticked (checked)
when activated. Checkboxes are used to let a user select
one or more options of a limited number of choices. Tip:
Always add the <label> tag for best accessibility practices!
Adding a radio control:
Use the <input type=”radio”> element within <form> tags,
ensuring each radio button has the same name attribute to
group them together. Getting the Selected Radio Button
Value: Access the value property of the selected radio
button to retrieve the chosen option.

Adding a password field:


This can be done by using the <input> tag with type attribute
which is set to the value “password“. It involves sensitive
information about the data of the user. The text in the input
password field will be changed into bullets in the view of
hiding from the third party.

Adding a drop-down list:


A basic HTML dropdown can be created using the <select>
and <option> elements. Each <option> represents an item in
the dropdown list, and the value attribute specifies the value
submitted to the server.

Adding buttons:
The most commonly used buttons are Submit and Reset.
They are used when we have entered all the details in the
form.
Submit: When we click on this button, then the data which is
entered in the fields will be sent to server as a series of name
and value pairs. The “Name” being the name of the form and
the value is the input value entered by the user in the field.
Reset: The Reset button is used to clear the contents and set
the values of all the form elements to their initial state and
activate them.

Adding a multiline text field:


The <textarea> tag defines a multi-line text input control.
The <textarea> element is often used in a form, to collect
user inputs like comments or reviews. A text area can hold
an unlimited number of characters, and the text renders in
a fixed-width font (usually Courier).

Some extra Q&As :


Q1) Define the input attributes.
A1) This tag is used to input values in the form. It has various
attributes.
Type- This attribute specifies the kind of form control which
will be added to the form. The default type is “Text”.”
Name- This attribute specifies the name of the <Input>
element.
Value- This attribute specifies the initial value for the
element.
Size- This attribute specifies the width of the input field.
Maxlength- This attribute specifies the maximum number of
characters for the input field.

Q2) What is the use of reset button?


A2) The reset button is used to clear the contents and set the
values of all the form elements to their initial state and
activate them

Q3) How to accept many lines of text from the user?


A3)At times we need to accept many lines of text from the
user. So, in these cases, we need to use the <Textarea> tag.
It has a name attribute and we need to specify the number of
rows and columns by using the rows and cols attributes. The
rows and columns determine the size of the Textarea
control. A user can type the text within the defined text area.
Q4) What is the use of Textbox?
A4) A Textbox allows a user to enter the alpha-numeric data
in the form. An alpha-numeric data is a combination of
characters and numbers.

You might also like