Forum digitalis

1.9 Forms

Forms

HTML forms are created using the <form> element. Inside a form, various input types can be used, such as text, email, password, date, or number. The <label> element labels input fields, and <button> is used to submit the form. Attributes like required enforce input, while placeholder provides placeholder text.

Example

The following example shows a simple form with different input fields.

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Forms</title> </head> <body> <form action="#" method="post"> <label for="name">Name:</label> <input type="text" id="name" name="name" placeholder="Your Name" required> <br> <label for="email">Email:</label> <input type="email" id="email" name="email" placeholder="email@example.com" required> <br> <label for="password">Password:</label> <input type="password" id="password" name="password" required> <br> <label for="birthday">Birthday:</label> <input type="date" id="birthday" name="birthday"> <br> <label for="quantity">Quantity:</label> <input type="number" id="quantity" name="quantity" min="1" max="10"> <br> <button type="submit">Submit</button> </form> </body> </html>