HTML Forms

HTML Forms

HTML form is used to collect user input.

The user input is most often sent to a server for processing by using php

HTML <form> element is used to create an HTML form for user input:


Forms Guideline

starting for opening <form> tag

HTML <input> element is the most used form element.


HTML Forms example

                                                    
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Styled Form Example</title>
</head>
<body>

  <form>
    <label for="firstName">First name:</label>
    <input type="text" id="firstName" name="firstName" required>

    <label for="lastName">Last name:</label>
    <input type="text" id="lastName" name="lastName" required>

    <input type="submit" value="Submit">
  </form>

  <!-- Add more content or elements as needed -->

</body>
</html>
                                                    
                                                

The <form> Element

                                                    
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Styled Form Example</title>
</head>
<body>
  <form>
  </form>
</body>
</html>
                                                    
                                                

The <input> Element

HTML form input types are used to create different types of form fields where users can input data.

Form Element Description

<input type="text">

Text Field

<input type="button">

Button Field

<input type="checkbox">

Checkbox Field

<input type="date">

Date Field

<input type="email">

Email Field

<input type="password">

Password Field

<input type="file">

File Field

<input type="image">

Image Field

<input type="radio">

Radio Field

<input type="reset">

Reset Field

<input type="search">

Search Field

<input type="submit">

Submit Field

<input type="time">

Time Field

<input type="url">

Url Field

<input type="week">

Week Field

<input type="hidden">

Hidden Field