InterviewSolution
| 1. |
Explain forms in HTML. |
|
Answer» While surfing net, we come across many websites to GET the information which we want to get, along with this we also come across some websites which have formed in the bottom or they POP up a form for the user to enter his/her information. To create a form in our website we use the <form> tag. Inside the form tag, we create text area, checkbox, radio buttons, Drop down buttons, etc to gather the information of the site visitor. GENERALLY, once the user fills the form and clicks the Submit button, all the data is taken and send to some backend server. On the backend server, it is stored in some database. The <form> tag have two important attributes - action and method. The action attribute specifies the backend script to process your data like a PHP script. The method specifies the method for API calls - mostly GET or POST. The form example is below. <!DOCTYPE html> <html> <head> <title>Form tutorials</title> <style> form{ display: grid; place-content: center; } </style> </head> <BODY> <form action="/action_page.php" method="get"> <h1>Complete Form</h1> <div class="form-example"> <label for="name">Enter your name: </label> <input type="text" name="name" id="name" required> </div> <div class="form-example"> <label for="email">Enter your email: </label> <input type="email" name="email" id="email" required> </div> <div class="form-example"></div> <label for="desc">Enter your description: </label> <br> <textarea id="desc" rows="5" cols="35" name="description"> Enter description here... </textarea> </div> <div class="form-example"> <input type="submit" value="Subscribe!"> </div> </form> </body> </html> |
|