<!DOCTYPE html>
<html>
<head>
<title>HTML Form Example</title>
</head>
<body>
<h1>Contact Form</h1>
<form action=”/submit” method=”post”>
<!– Text Input –>
<label for=”name”>Name:</label><br>
<input type=”text” id=”name” name=”name”><br><br>
<!– Email Input –>
<label for=”email”>Email:</label><br>
<input type=”email” id=”email” name=”email”><br><br>
<!– Textarea –>
<label for=”message”>Message:</label><br>
<textarea id=”message” name=”message” rows=”4″ cols=”40″></textarea><br><br>
<!– Radio Buttons –>
<p>Gender:</p>
<input type=”radio” id=”male” name=”gender” value=”male”>
<label for=”male”>Male</label><br>
<input type=”radio” id=”female” name=”gender” value=”female”>
<label for=”female”>Female</label><br><br>
<!– Checkboxes –>
<p>Subscribe to:</p>
<input type=”checkbox” id=”news” name=”subscribe” value=”newsletter”>
<label for=”news”>Newsletter</label><br>
<input type=”checkbox” id=”updates” name=”subscribe” value=”updates”>
<label for=”updates”>Product Updates</label><br><br>
<!– Dropdown (Select) –>
<label for=”country”>Choose your country:</label><br>
<select id=”country” name=”country”>
<option value=”norway”>Norway</option>
<option value=”sweden”>Sweden</option>
<option value=”denmark”>Denmark</option>
</select><br><br>
<!– Submit Button –>
<input type=”submit” value=”Send Message”>
</form>
</body>
</html>
(SEE RESULT)
Tags Used
| Tag | Purpose |
| <form> | Main form container |
| <label> | Describes what each field is for |
| <input> | Various types: text, email, radio, checkbox |
| <textarea> | Multi-line text box |
| <select> | Dropdown list |
| <option> | Options inside a dropdown |
| <br> | Line break |
| <input type=”submit”> | Submit button |
