0% found this document useful (0 votes)
4 views16 pages

HTML Forms: Elements & Attributes Guide

This document provides an overview of creating forms using HTML tags, detailing the purpose of HTML forms for collecting user input and sending it to a server. It explains various form attributes, including the method (GET and POST) and action attributes, as well as different input types such as text, password, radio, checkbox, and more. Additionally, it covers the creation of dropdown lists using the <select> element and multi-line text inputs using the <textarea> tag.

Uploaded by

3385
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views16 pages

HTML Forms: Elements & Attributes Guide

This document provides an overview of creating forms using HTML tags, detailing the purpose of HTML forms for collecting user input and sending it to a server. It explains various form attributes, including the method (GET and POST) and action attributes, as well as different input types such as text, password, radio, checkbox, and more. Additionally, it covers the creation of dropdown lists using the <select> element and multi-line text inputs using the <textarea> tag.

Uploaded by

3385
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

HTML TAGS


Learning Objective

Creating FORMS using HTML tags.
FORMS IN HTML

WATCH VIDEO
[Link]
Identify the form elements

FORMS IN HTML
 An HTML form is used to collect user input. The user input can then be
sent to a server for processing.

Form Attributes
 The HTML <form> method Attribute is used to specify the HTTP method used to
send data while submitting the form. There are two kinds of HTTP methods,
which are GET and POST.
 GET is better for the data which does not require any security or having images or
word documents.
 POST is used to send data to a server to create/update a resource in a secure
way.
 Action Attribute is used to specify where the form data is to be sent to the server
after submission of the form. Attribute Values: URL: It is used to specify the URL
of the document where the data to be sent after the submission of the form.
EX: <form action="/action_page.php" method="get">
<INPUT>
Here are the different input types you can use in
HTML:
<input type="text">
<input type="password">
<input type="radio">
<input type="checkbox">
<input type="reset">
<input type="submit">
<input type="button">
Attributes are: name, value
<INPUT>
 <input type="text" name=“n1“ value=“Enter your name”>

<input type="password" name="pwd">

GENDER<input type="radio" name="g1" value="female">FEMALE


<input type="radio" name="g1" value=“male">MALE

Hobbies:<input type="checkbox" name="c1" value="chess">Play chess


<input type="checkbox" name="c2" value="book">Reading book
<INPUT>
Here are the different input types you can use in HTML:

<input type="submit" name="s1" value="CLICK">

<input type="image" src="img_submit.gif" alt="Submit"


width=“50" height=“50">

<button type="button" onclick=“alert('submit the data')">Click me

<input type="reset">
TEXT AREA,COMBO BOX

How to add a text area?


How to add a combo box/drop down list?
Drop down list/Combo box
The <select> element is used to create a drop-
down list.

The <option> tags inside


the <select> element define the available
options in the drop-down list.

Attributes are: size, multiple , name ,


disabled
Drop down list
<select name="favcolor">
<option>GREEN</option>
<option>BLUE</option>
<option>YELLOW</option>
<option>ORANGE</option>
</select>
<select name="favcolor“ size=“3”>
Text area
The <textarea> tag defines a multi-line
text input control.
A text area can hold an unlimited number
of characters.
The size of a text area can be specified by
the cols and rows attributes.
Text area
<textarea name="t1" rows="4" cols="50">
Enter the address here
</textarea>
TASK SHEET

THANK YOU !!!

Common questions

Powered by AI

The 'input type="reset"' feature clears all existing user inputs in a form, reverting data to its default values. This can be beneficial in cases where users wish to quickly discard all input data without reloading the page. However, it can also be risky if clicked accidentally, as it results in loss of potentially lengthy input, which can be frustrating for users. Its placement and use should be carefully considered in form design to prevent unintended data loss.

The 'input type' attributes in HTML forms define the type of data input field provided to the user. 'input type="text"' is used for single-line text fields where users can enter data such as names or numbers. 'input type="password"' masks the entered characters, securing it during typing, typically used for passwords. 'input type="radio"' presents a set of options from which users can choose one, such as gender options, ensuring exclusive selection among related choices. Proper usage involves setting appropriate names and values to group related inputs and ensure server-side processing.

The 'select' element is used in HTML forms to create dropdown lists, allowing users to choose from several predefined options. Attributes such as 'size' and 'multiple' control how many options are visible at once and whether multiple selections are allowed, respectively. The 'name' attribute is necessary for associating the selection with a form variable. Customizing these attributes enhances usability by tailoring the dropdown list to fit form design and user interaction requirements.

The 'textarea' tag is crucial for capturing multi-line input from users, such as addresses or comments. It allows for an unrestricted number of characters, unlike single-line inputs. The 'cols' and 'rows' attributes define the visible size of the text area, helping to control the width and height of the display, which enhances user experience by making it easier to review and edit input without restrictive scrolling.

The 'GET' method appends the form data to the URL, making it visible in the browser's address bar, which is useful for data that can be seen and easily repeated, such as search queries. Due to this visibility, 'GET' is not suitable for sensitive data. It is also typically limited by URL length restrictions. On the other hand, the 'POST' method sends data as an HTTP request body, obscuring it from the URL and allowing for larger amounts of data to be sent securely, making it ideal for confidential information like passwords. 'POST' is used for creating or updating resources on the server.

The 'action' attribute in an HTML form specifies the URL where the form data will be sent upon submission. Specifying the correct URL is essential because it determines the server endpoint that will receive and process the form data. If the URL is incorrect or omitted, data may not be sent to the intended destination, leading to processing failures or errors.

To create a dropdown list in an HTML form, use a 'select' element to define the dropdown container, then include 'option' elements to represent each selectable item. Attributes such as 'size' can control viewing dimensions, and 'multiple' allows more than one selection. The 'disabled' attribute can be applied to individual 'option' elements to prevent users from selecting particular choices, which might be necessary to indicate unavailable options or to guide user interaction based on context.

HTML form elements function as user interfaces for data collection and play a pivotal role in web application data flow. By allowing input types ranging from text fields to option selections, these elements facilitate structured data gathering. Understanding their attributes and functionalities is critical because it ensures the correct processing and security of data, optimizes user experience, and aligns form interactions with backend data handling methods, maintaining the integrity and efficiency of web applications.

'input type="checkbox"' allows users to select multiple options independently in HTML forms, offering flexibility in selections such as multiple hobbies or interests. In contrast, 'radio' inputs are used where exactly one selection is allowed among a set of exclusive options, ensuring mutual exclusivity. The decision between them depends on whether single-choice or multiple-choice answers are needed from the user.

The 'button' element with an 'onclick' attribute in HTML forms is designed for interactions that trigger client-side actions, such as JavaScript functions, and does not automatically submit form data. In contrast, a traditional 'submit' button automatically sends all form data to the server without requiring additional scripting. Use the 'button' with 'onclick' for client-specific tasks prior to or instead of data submission.

You might also like