HTML Basics

HTML Introduction HTML Basic HTML Comments HTML Tags/Elements HTML Attributes HTML Formatting HTML Block and Inline HTML Charsets HTML Classes HTML Colors HTML Div HTML Headings HTML Id HTML Iframes HTML Images HTML File Paths HTML Tables HTML Layout HTML Lists HTML Links <a> HTML Paragraphs HTML Quotations HTML JavaScript HTML Emojis HTML URL Encode HTML Entities HTML Computercode HTML Symbols HTML Styles

HTML Forms

HTML Forms HTML Form Elements HTML Form Attributes HTML Input Attributes HTML Input Regex HTML Input Form Attributes HTML Input Types

HTML SEO

HTML Head HTML Page Title HTML Responsive HTML Semantics HTML Favicon

HTML Graphics

HTML Canvas HTML SVG

HTML Media

HTML Media HTML Audio HTML Video

HTML Reference

a abbr acronym address applet area article aside audio b base basefont bdi bdo big blockquote body br button canvas caption center cite code col colgroup data datalist dd del details dfn dialog dir div dl DOCTYPE dt em embed fieldset figcaption figure font footer form frame frameset h1_-_h6 head header hgroup hr html i iframe img input ins kbd label legend li link main map mark menu meta meter nav noframes noscript object ol optgroup option output p param picture pre progress q rp rt ruby s samp script search section select small source span strike strong style sub summary sup svg table tbody td template textarea tfoot th thead time title tr track tt u ul var video wbr

HTML <form> Tag

The <form> tag is used to create an HTML form for collecting user input. It can contain various input elements such as text fields, checkboxes, radio buttons, submit buttons, etc. When a form is submitted, the data entered by the user is sent to a server for processing.

Basic Syntax

<form action="url_to_submit_data" method="post/get">
  
</form>

The <form> tag has two main attributes:

Attribute Description
action Specifies the URL to which the form data will be submitted. This URL can be a relative or absolute path. When the form is submitted, the browser will navigate to this URL.
method Specifies how the form data will be sent. The two most common methods are post and get. post sends the data in the body of the request, while get appends the data to the URL.

Example

Let's create a simple login form using the <form> tag:

<form action="/login" method="post">
  <label for="username">Username:</label>
  <input type="text" id="username" name="username">
  <br>
  
  <label for="password">Password:</label>
  <input type="password" id="password" name="password">
  <br>
  
  <input type="submit" value="Login">
</form>

In this example, when the user enters their username and password and clicks the "Login" button, the form will be submitted to the "/login" URL using the post method.

Remember to always include a submit button (input with type="submit") in your form so that users can submit their input.