ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Create a Simple Form in HTML

Updated on October 11, 2011

The introduction of Hyper Text Markup Language (HTML) and the Hyper Text Transfer Protocol (HTTP) brought about the Internet revolution known as the World Wide Web. In those early days, all web pages were static by nature, meaning pages looked the same every time they were viewed.

Interactive content did not exist. Web designers were limited to displaying the same information over and over. There was also no way to collect feedback from viewers or generate sales online. The introduction of HTML forms gave authors a method to solicit feedback and resulted in the introduction of e-Business technologies and online catalogues.

The goal of any Web master is creating sticky Web sites. Creating interactive Web pages is a must to make a site sticky. What is a sticky site? This is a site that users visit over and over. One of the simplest ways to promote interactivity in a site is to use HTML forms. Forms provide areas for users to supply input to change the content of the site, provide feedback, request information, or take advantage of other functionality.

Before we go any further, I should explain that this hub assumes that you understand how to create a basic Web page using essential HTML tags and how to create a table using HTML. Further, the code snippets included in these tutorial hubs only include the code for the demonstrated elements, in this case -- a form.

Let's create a simple form using HTML to display on a Web page. This particular form will render using a table format, although we could use a more free-flowing format, such as the paragraph. To view the form that appears in the following code snippet in a Web browser, insert the code inside the body element of a HTML document.

  <form action="retrieveInfo.asp" method="get" id="contactForm" name="contactForm">
      <tr><th colspan="2">Simple Contact Form</th></tr>
      <tr><td>First Name: </td><td><input type="txt" name="fname" /></td></tr>
      <tr><td>Last Name: </td><td><input type="txt" name="lname" /></td></tr>
      <tr><td>E-mail: </td><td><input type="txt" name="email" /></td></tr>
      <tr><td></td><td><input type="submit" value="Submit" /></td></tr>
      <tr><td colspan="2">Submit Form for more Information</td></tr>

The HTML Form Element

The above code snippet for a simple form introduces a couple new elements to our HTML arsenal. These elements are the form and input elements, identified by the HTML <form> ... </form> and <input> ... </input> tag pairs. Everything between the opening (<form>) tag and the closing </form>) tag are part of the form.

Notice that the form element includes a number of attributes or descriptive items within the tag. These attributes include the following:

  • action="retrieveInfo.asp"
  • method="get"
  • id="contactForm"
  • name="contactForm"

The attributes instruct the browser what to do with the form data supplied by the user and identify the form for later use. The action attribute works with the submit input element covered below and instructs the server receiving the form data to handle the data using the retrieveInfo.asp server side script; more on server side scripting in a later hub but understand that most HTML documents originate from Web servers and HTML forms may then communicate with those servers using forms. Therefore, when the user submits the data in the form to the server, the server handles the data using the script file identified by the action element.

Click image to view full size.
Click image to view full size.

The method attribute, in this case get, instructs the web browser how to supply the data to the server. There are two basic methods for browsers to communicate with web servers. Those two methods are get and post. The get method includes the data in a URL supplied to the server that requests, or gets, another page from the server. The server then processes the request and supplies the results back to the web browser to display for the client or site visitor. We did not use the post method and the description of that method is outside the scope of this hub.

The two attributes that are left are the id and name attributes. These attributes simply identify and name the form so that a client-side script, such as JavaScript, can refer back to the form after the form has been displayed or rendered by the browser.

The HTML Input Element

The HTML input elements identify areas where the page viewer may enter and submit data. The input element includes attributes on the lines where the elements are displayed. The most important attribute is in this case the type attribute. The type attribute of the input element identifies the type of input the viewer may provide.

The two types of input in this form are txt and submit. The txt type creates a text box where the user may type in data. This form includes three text boxes: the first name, last name, and e-mail text boxes. The form user may type data into the text boxes then submit the form to the server by clicking on the submit button created by the submit input type. When the user clicks on the submit button, the form data is submitted to the server using the method identified by the method attribute in the above form element.

Note: There are other attributes and input types that may be used when creating forms. And many styles may be used to modify the format of forms or how they display. Complete information on HTML is available from

We have now created a simple form that requests contact information from a user. For ideas on what you can do with the data in a form within a browser, continue to retrieve data from an HTML form.

Was this hub interesting, Id love to hear from you,

Please leave a comment.


    0 of 8192 characters used
    Post Comment
    • Dumbledore profile imageAUTHOR

      This Old Guy 

      9 years ago from Somewhere in Ohio

      Thank you, tamirindcandy; I will be publishing more of these.

    • tamarindcandy profile image


      9 years ago

      Neat tutorial!


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
    ClickscoThis is a data management platform studying reader behavior (Privacy Policy)