HTML forms allow users to enter data that gets sent to a web server for processing. Forms are commonly used for login screens, surveys, registration, feedback, and more.
<form>...</form>
<form>
<label for="name">Name:</label>
<input type="text" id="name" name="name">
</form>
<label>
is used to describe what the user should enter. The for
attribute should match the input id
.
<input type="email" name="email" placeholder="Enter your email">
<input type="password" name="password" placeholder="Enter your password">
These fields validate user input to match the correct format.
<textarea name="message" rows="4" cols="30">Write your message here...</textarea>
<input type="submit" value="Send">
<textarea>
is for longer messages. <input type="submit">
creates the form's submit button.
<form action="/submit" method="post">
<label>Name: </label>
<input type="text" name="name"><br>
<label>Email: </label>
<input type="email" name="email"><br>
<label>Message: </label><br>
<textarea name="message" rows="4" cols="30"></textarea><br>
<input type="submit" value="Submit">
</form>
This form sends data to /submit
using POST method.
name
attributes to ensure your form data can be collected by the backend!Create a form that collects: