Introduction to Forms in HTML
Forms are used to collect user input and send it to a server.
Basic Form Structure
<form action="submit.php" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<input type="submit" value="Submit">
</form>
HTMLForm Elements
Input Fields
<input type="text" placeholder="Enter text">
<input type="email" placeholder="Enter email">
<input type="password" placeholder="Enter password">
HTMLTextarea
<textarea rows="4" cols="50">Type here...</textarea>
HTMLDropdown Select
<select>
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
</select>
HTMLCheckboxes & Radio Buttons
<input type="checkbox" id="agree" name="agree">
<label for="agree">I agree</label>
<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> Female
HTMLForm Attributes
action
& method
action
: Specifies the URL where form data is sent.method
: Can beGET
orPOST
.
<form action="process.php" method="post">
HTMLautocomplete
<input type="text" name="username" autocomplete="on">
HTMLAdvanced Form Elements
File Upload
<input type="file">
HTMLForm Buttons
<button type="submit">Submit</button>
<button type="reset">Reset</button>
HTMLHTML forms help collect user input effectively. Next, we’ll discuss multimedia integration.