HTML5 & Web APIs (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
How do standard HTML forms work and what are the native form controls?
junior LevelCode ExampleForms
In Simple Words:
A <form> collects user input and transmits it to a server endpoint via an HTTP method:
action: The server URL endpoint to which data is submitted.method: The HTTP method (GETappends form data to the URL query string;POSTtransmits data in the HTTP request body).- Core Form Elements:
<input>: Single-line input with diverse types.<textarea>: Multi-line text input.<select>&<option>: Dropdown picker.<fieldset>&<legend>: Groups related form controls semantically with a caption.
html
<form action="/api/v1/subscribe" method="POST">
<fieldset>
<legend>Newsletter Subscription</legend>
<label for="user-email">Email Address:</label>
<input id="user-email" name="email" type="email" required autocomplete="email" />
<button type="submit">Subscribe</button>
</fieldset>
</form>