How to define a form for user input using HTML5 ?

In this article, we will learn how to create a form in a webpage by using the <form> tag. This tag is used to create form for user input. Also there are many elements which are used within form tag.

Syntax:

<form> Form Content... </form>

Example: The following code snippet demonstrates the simple creation of form.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML5: How to define an 
        HTML form for user input?
    </title>
  
    <style>
        body {
            text-align: center;
        }
  
        h1 {
            color: green;
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
  
    <h2>
        HTML5: How to define an 
        HTML form for user input?
    </h2>
  
    <form action="#">
        First name:
        <input type="text" 
            placeholder="First Name" value="">
        <br><br>
  
        Last name:
        <input type="text" 
            placeholder="Last Name" value="">
        <br><br>
          
        <input type="submit" value="Submit">
    </form>
</body>
  
</html>                

chevron_right


Output :

Supported Browsers:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.