How to Create an HTML Form | HTML Goodies

How to Create an HTML Form

Written By
Octavia Anghel
Octavia Anghel
May 31, 2018
4 minute read

Learn how to create, implement and style HTML Forms via CSS. You will also see how to upload them to a server.

Through HTML forms, forms that are inserted into web pages, we can enter text, numbers, we can select a single option from a list, we can check a check box or choose a radio button. These forms can be simple or extensive, attractive and easy to use, with an elegant design or complex features, but the most important thing is that the forms created are functional.

After the introduction above, I’d like to start with a definition of an HTML form. So, an HTML form is part of a document that has form elements, selection boxes, menus, radio buttons, text fields, submit buttons, markup and so on. Through HTML forms, users can send to the website and to the web server.

Here’s an example of a form that contains a submit button, a reset button, radio buttons, and labels:

<html>
<body>
<h1>HTML form</h1>
<form action="post">
    <p>
    <label for="firstname">First name: </label>
              <input type="text" name="firstname"><br>
              <br>
    <label for="lastname">Last name: </label>
              <input type="text" name="lastname"><br>
              <br>
    <label for="email">E-mail: </label>
              <input type="text" id="E-mail"><br>
              <br>
    <input type="radio" value="Male"> Male<br>
    <input type="radio" value="Female"> Female<br>
    <br>
    <input type="submit" value="Submit"> <input type="Reset">
    </p>
 </form>
</body>
</html>

So, all HTML forms start with the

element. This element defines a form , having different optional attributes.

The element is a meaningful element and can be displayed differently by the attribute that we distribute to it: the “radio” attribute, the “text” attribute, the “submit.” “reset,” “e-mail,” “choose file,” “password.” Let’s take a few examples in the lines below:

Radio Button

<html>
<body>
<h1>Text Input = "radio" </h1>
<form>
  <p>Please select your favorite season:</p>
  <div>
    <input type="radio" name="season"
     name="season" value="spring" >
    <label for="season">Spring</label>
    <input type="radio" name="season"
     name="season" value="Summer" checked>
    <label for="season">Summer</label>
    <input type="radio" name="season"
     name="season" value="fall"  >
    <label for="season">Fall</label>    
    <input type="radio" name="season"
     name="season" value="Winter"  >
    <label for="season">Winter</label>
  </div>
  <div>
    <button type="submit">Submit</button>
  </div>
</form>
</body>
</html>

Submit Button

<html>
<body>
<h1>Submit button example </h1>
<form> 
  <div>
    <label for="example">Write your name, then submit</label>
    <input name="example" type="text" name="text">
  </div>
  <br>
  <div>
    <input type="submit" value="Submit">
  </div>
</form> 
<p>That's the only way we know who we're getting in touch with</p>
</body>
</html>

Reset Button

<html>
<body>
<h1>Reset button example </h1>
<form> 
  <div>
    <label for="example">Write some text</label>
    <input name="example" type="text">
  </div>
  <br>
  <div>
    <input type="reset" value="Reset form">
  </div>
</form> 
<p>If you want to reset the form, then click on the reset button</p>
</body>
</html>

Checkbox

<html>
<body>
<h1>Checkbox example </h1>
<form>
  <div>
    <input type="checkbox" name="subscribeforupdates" name="subscribe" value="updates">
    <label for="subscribe">Subscribe for updates?</label>
  </div>
  <br>
  <div>
    <button type="submit">Subscribe now!</button>
  </div>
</form>
<p>Subscribe for the latest and fresh updates</p>
</body>
</html>

Password

<html>
<body>
<h1>Password example </h1>
<label for="Password">Password: </label>
<input name="Password" type="password" required>
<input type="submit" value="Submit">
<p><h3>Enter your password<h3> </p>
</body>
</html>

Choose File

<html>
<body>
<h1>Choose file example</h1>
<form method="post">
  <div>
    <label for="photo">Choose file for upload</label>
    <input type="file" name="photo" name="photo"
          accept=".gif, .bmp, .png, .jpg, .jepg,">
  </div>
  <div>
    <button>Submit</button>
  </div>
</form> 
<p>FILE UPLOAD FORM</p>
</body>
</html>

The

HTML Goodies Logo

The original home of HTML tutorials. HTMLGoodies is a website dedicated to publishing tutorials that cover every aspect of being a web developer. We cover programming and web development tutorials on languages and technologies such as HTML, JavaScript, and CSS. In addition, our articles cover web frameworks like Angular and React.JS, as well as popular Content Management Systems (CMS) that include WordPress, Drupal, and Joomla. Website development platforms like Shopify, Squarespace, and Wix are also featured. Topics related to solid web design and Internet Marketing also find a home on HTMLGoodies, as we discuss UX/UI Design, Search Engine Optimization (SEO), and web dev best practices.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.