Basic Form Structure
Forms are used to collect user input and send it to a server for processing.
<form action="/submit" method="POST">
<!-- Form controls go here -->
</form>
action
- Specifies where to send the form data
method
- Specifies the HTTP method (GET or POST)
enctype
- Specifies how form data should be encoded (important for file uploads)
Form Controls
Text Input
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
Email Input
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
Password Input
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
Radio Buttons
<fieldset>
<legend>Gender</legend>
<label><input type="radio" name="gender" value="male"> Male</label>
<label><input type="radio" name="gender" value="female"> Female</label>
</fieldset>
Checkboxes
<label><input type="checkbox" name="subscribe" checked> Subscribe to newsletter</label>
Select Dropdown
<label for="country">Country:</label>
<select id="country" name="country">
<option value="us">United States</option>
<option value="ca">Canada</option>
</select>
Textarea
<label for="message">Message:</label>
<textarea id="message" name="message" rows="4"></textarea>
Buttons
<button type="submit">Submit</button>
<button type="reset">Reset</button>
<button type="button">Regular Button</button>