Forms & Basic Inputs

🌐 HTML Basics Lesson 8 Beginner

Forms send user-entered details to server-side scripts for processing. HTML supports form actions, HTTP methods, and diverse input types.

1 form action, GET/POST methods, and input types

Common form properties include:

  • action Attribute: Specifies the target server URL where the form data will be sent.
  • method Attribute: Specifies the HTTP request type. Use `GET` for searches, and `POST` for passwords or operations that modify data on the server.
  • input types: HTML5 supports specific input validation types (e.g. `text`, `password`, `email`, `checkbox`, `radio`).
2 Form Elements Code

Let's check form layouts:

HTML — Simple Form
<form action="/submit-form" method="POST">
    <label for="email">Email Address:</label>
    <input type="email" id="email" name="user_email" placeholder="email@example.com">
    
    <label for="pass">Password:</label>
    <input type="password" id="pass" name="user_password">

    <button type="submit">Login</button>
</form>
3 Code Challenge
Challenge: Write a form containing radio buttons where users select their favorite programming language. Give them the same `name` attribute to ensure only one option can be selected at a time.