YouTip LogoYouTip

HTML Forms and Input Types

HTML Forms

Forms collect user input and send it to a server.

<form action="/submit" method="POST">
    <label for="name">Name:</label>
    <input type="text" id="name" name="name" required>

    <label for="email">Email:</label>
    <input type="email" id="email" name="email">

    <label for="msg">Message:</label>
    <textarea id="msg" name="message"></textarea>

    <select name="role">
        <option value="user">User</option>
        <option value="admin">Admin</option>
    </select>

    <button type="submit">Submit</button>
</form>

Input Types

text, email, password, number, tel, url, date, color, file, checkbox, radio, range, search

Summary

  • Forms use action and method attributes
  • Input types provide built-in validation
  • Label elements improve accessibility
← HTML Tables and ListsHTML Elements and Attributes β†’