A website isn't just a brochure. To be useful, it needs to collect information from the user and send it back to the server. Without this, features like login, search, shopping, and messaging wouldn't exist.
The solution is the HTML <form> element.
<form>
<input type="text">
</form>
<label>First Name:</label>
<input type="text">
<label for="firstName">First Name:</label>
<input type="text" id="firstName">
<form>
<label for="firstName">First Name:</label>
<input type="text" id="firstName">
<br><br>
<label for="lastName">Last Name:</label>
<input type="text" id="lastName">
<br><br>
<input type="submit">
</form>
<form>
<label for="firstName">First Name:</label>
<input type="text" id="firstName" name="firstName">
<br><br>
<label for="lastName">Last Name:</label>
<input type="text" id="lastName" name="lastName">
<br><br>
<input type="submit">
</form>
<label>T-Shirt Size:</label><br>
<input type="radio" id="sizeS" name="shirtSize" value="small">
<label for="sizeS">Small</label><br>
<input type="radio" id="sizeM" name="shirtSize" value="medium">
<label for="sizeM">Medium</label><br>
<input type="radio" id="sizeL" name="shirtSize" value="large">
<label for="sizeL">Large</label><br><br>
<label>Pizza Toppings:</label><br>
<input type="checkbox" id="toppingPep" name="toppings" value="pepperoni">
<label for="toppingPep">Pepperoni</label><br>
<input type="checkbox" id="toppingMush" name="toppings" value="mushrooms">
<label for="toppingMush">Mushrooms</label><br>
<input type="checkbox" id="toppingOni" name="toppings" value="onions">
<label for="toppingOni">Onions</label><br><br>
<!-- OLD WAY -->
<input type="submit" value="Submit Your Order">
<!-- NEW WAY -->
<button type="submit">
<strong>Submit</strong> Your Order
</button>
<label for="comments">Any special instructions?</label><br>
<textarea id="comments" name="comments" rows="4" cols="50"></textarea><br><br>
<label for="country">Country:</label><br>
<select id="country" name="country">
<option value="">--Please choose an option--</option>
<option value="in">India</option>
<option value="us">USA</option>
<option value="uk">United Kingdom</option>
<option value="au">Australia</option>
</select><br><br>
<label for="userPass">Password:</label><br>
<input type="password" id="userPass" name="userPassword"><br><br>
<label for="userAge">Age (18-99):</label><br>
<input type="number" id="userAge" name="age" min="18" max="99"><br><br>
<label for="birthDate">Date of Birth:</label><br>
<input type="date" id="birthDate" name="dob"><br><br>
Code:
<form action="">
<label for="uname">Name</label>
<input type="text" name="username" id="uname" />
<br><br>
<label for="fname">Father Name</label>
<input type="text" name="userFname" id="fname" />
<br><br>
<label for="age">Age</label>
<input type="number" name="userage" id="age" />
<br><br>
<label for="pass">Password</label>
<input type="password" name="userpass" id="pass"/>
<br><br>
<label for="male">Male</label>
<input type="radio" name="gender" id="male" value="male"/>
<label for="female">Female</label>
<input type="radio" name="gender" id="female" value="female"/>
<label for="other">Other</label>
<input type="radio" name="gender" id="other" value="other"/>
<br><br>
<label for="c++">C++</label>
<input type="checkbox" id="c++" name="subject" value="c++"/>
<label for="java">Java</label>
<input type="checkbox" id="java" name="subject" value="java"/>
<label for="javascript">Javascript</label>
<input type="checkbox" id="javascript" name="subject" value="javascript"/>
<label for="python">Python</label>
<input type="checkbox" id="python" name="subject" value="python"/>
<br><br>
<input type="submit">
</form>
Output:
Code:
<form action="">
<label for="fname">First Name</label>
<input type="text" placeholder="e.g.Aryan" id="fname" />
<br><br>
<label for="lname">Last Name</label>
<input type="text" placeholder="e.g.Kumar" id="lname" />
<br><br>
<label>Date of Birth</label>
<input type="date" />
<br><br>
<label>Gender</label>
<br>
<input type="radio" name="gender" id="male" /><label for="male">Male</label>
<br>
<input type="radio" name="gender" id="female" /><label for="female">Female</label>
<br>
<input type="radio" name="gender" id="other" /><label for="other">Other</label>
<br><br>
<label for="file">Upload photo</label>
<br>
<input type="file" id="file" />
<br><br>
<!-- More fields: Email, Phone, Address, Course, Interests, Password, Security Question -->
</form>
Output: