HTML Tags and Form
HTML Tags and Form
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Forms</title>
</head>
<body>
<h2>This is HTML forms tutorial</h2>
<form action="backend.php">
<label for="name"> Name</label>
<div>
<input type="text" name="myName" id="name">
</div>
<br>
<div>
Role: <input type="text" name="myRole">
</div>
<br>
<div>
Email: <input type="email" name="myEmail">
</div>
<br>
<div>
Date: <input type="date" name="myDate">
</div>
<br>
<div>
Bonus: <input type="number" name="myBonus">
</div>
<br>
<div>
Are you eligible?: <input type="checkbox" name="myEligibility" checked>
</div>
<br>
<div>
Gender: Male <input type="radio" name="myGender"> Female <input
type="radio" name="myGender">
Other <input type="radio" name="myGender">
</div>
<br>
<div>
Write about yourself: <br><textarea name="myText" cols="90"
rows="10"></textarea>
</div>
<br>
<div>
<label for="car">Car</label>
<select name="myCar" id="car">
<option value="ind">Indica</option>
<option value="swf" selected>Swift</option>
</select>
</div>
<br>
<div>
<input type="submit" value="Submit Now">
<input type="reset" value="Reset Now">
</div>
</form>
</body>
</html> tutorial 8 about forms and tags html
This HTML tutorial involves the learning of forms and Input tags used in HTML. We
are going to start by making a new HTML file as “tut8.html” and adding a
boilerplate through Emmet abbreviation. Forms are a very important part of HTML. It
represents the document section containing interactive controls for submitting
information.
Whenever we add a <form> tag in the HTML, it is going to ask for some action for
submitting that particular form in the backend for future reference. So, for now,
we will write it as backend.php. All the data submitted in a form will be stored
automatically in the backend “backend.php” after submitting it.
The <span> is an in-line element and <div> is a block element. Which means, if we
use two separate div tags for different inputs, then all the inputs will come on
different lines. We will learn about the span and div in detail in the upcoming
tutorial. Till then we will use the <br> tags for breaking a line.
To add any numeric text in the HTML form, the syntax is-
<div>
Number: <input type= “number” name “myNumber”>
</div>
While filling several online forms, you must have seen the radio buttons and
checkboxes in the form. Radio buttons are such buttons that allows to select any
one of the following options amongst all. For example, while selecting the gender,
we can only select either male or female. Whereas the checkbox allows selecting the
multiple options available. The example of both the formats are as follows-
For checkbox-
<div>
Are you eligible?: <input type="checkbox" name="myEligibility" checked>
</div>
For Radio buttons-
<div>
Gender: Male <input type="radio" name="myGender"> Female <input
type="radio" name="myGender">
Other <input type="radio" name="myGender">
</div>
To reset all the information, entered in the form, we take the help of a reset
button. To get the reset button, we have to write-
<div>
Input type= “reset” value= “Reset Now”
</div>
After inserting all these input tags, our form will look like-
These are some of the examples of basic input tags used inside the form in the
HTML. Apart from these, there are numerous more input tags available, but you need
not to learn all these at once. You can always take help of references available.
And one more advice, never try to grasp all things at once. Practice makes a man
perfect.