form Tag
FORM TAG
- Form tag allows us to accept input from a user.
- Each form contains a form element that contains special controls, such as buttons, text fields, checkboxes, Submit buttons, and menus.
- inside a <form> tag. The purpose of the <form> tag is to indicate where and how the user’s input should be sent
· Common Form Elements
- <input>
- <button
- <select>
- <textarea>
- <label>
A Attributes:
- Action: Action specifies the URL to which the form is submitted.
- Method: The method attribute supports two values: get and post.
- Name: The name of the
optional form.
- Target: It specifies
where to open the document that is the result of a form submission.
- Autocomplete: It tells the browser to attempt to predict the value when a user is
typing in a form control. It can have the value of on or off.
- Enctype: Enctype defines how form
data is encoded when it’s sent to the server
- Novalidate: Novalidate that lets you turn off validation on your forms
C Common <input> Types
Structure
<input type=”” id=”” value=””>
Example: <input type="email" id="email"
name="email" placeholder="example:@example.com">
Type: which specifies what kind of form control to display.
“Text” - Single-line text input
“Password” - Masked text input for passwords
“Checkbox”- Toggle for selecting multiple
options
“Radio”- Single selection from multiple options
“Submit”- Button to submit form data
“Button”- General-purpose button
Value: To display text in the text control before the user enters any information.
Name: It associates a name with the data entered in that field when the data is
sent to the server.
Placeholder: It make a suggestion as to what the user should write value
submitted other form data.
<fieldset> tag
Example: 1
<html>
<head><title> MY page </title></head>
<body>
<form action="#" method="post">
<fieldset>
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname"><br><br>
<label for="male">Gender:</label>
<input type="radio" id="male" name="gender" value="male">
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="female">
<label for="female">Female</label>
<input type="radio" id="other" name="gender" value="other">
<label for="other">Other</label><br><br>
<label for="subject">subject:</label>
<input type="checkbox" id="html" name="fav_language" value="HTML">
<label for="html">HTML</label>
<input type="checkbox" id="css" name="fav_language" value="CSS">
<label for="css">CSS</label>
<input type="checkbox" id="javascript" name="fav_languagevalue="JavaScript">
<label for="javascript">JavaScript</label><br><br>
   <input type="submit" value="Submit">
</fieldset>
</form>
</body>
</html>
OUT-PUT
The option tag inserted element in created drop-down menu.