How to create a form in an HTML page

HTML Form

An HTML form allows users to input data and interact with a website.

HTML form is used to allow users to input different types of data, such as text, passwords, numbers, dates, etc. and submit the data to the server for further action.

How to Create an HTML Form

Create an HTML <form> element.

Add a label <label>Your Name:</label> inside the form element. element.

Add a text input element <input type="text" id="myText" /> inside the form element.

Add a submit input element <input type="submit" id="btnSubmit" value="Submit Name" /> inside the form element as shown in the following.

Example of Dropdown List


Output of the above code example

Example of Form in a Webpage


This is an HTML form.

You can type your name in the text input box. But the form will not be submitted properly as form action attribute has not been defined yet.


Live Code Playground

In the following HTML code editor, you can practice the above code by adding more options to the select element. Click on the 'Run Code' button to render the code; the rendered page will be displayed in the following HTML Code Output frame. Practice until you become comfortable and proficient with your code.

HTML logo HTML Online Editor
HTML Code Output