<form>...</form>
HTML4 HTML5
Defines an HTML form used to collect user inputs and send them to a server. Contains interactive controls such as text fields, buttons, checkboxes, radio buttons, or select menus.
Both opening and closing tags are required.
Attributes:
action – URL where form data is submitted.
method – HTTP method used to submit data (typically GET or POST).
enctype – Encoding method (e.g., multipart/form-data for file uploads).
target – Specifies where to display response after submitting (e.g., _blank, _self).
autocomplete – Toggles field autocomplete (on or off).
novalidate – Disables default browser form validation.
Example
Code:
<form action="/submit" method="post" style="max-width: 300px; padding: 15px; border: 1px solid #ccc; border-radius: 4px; background-color: #f9f9f9;">
<div style="margin-bottom: 10px;">
<label for="imie" style="display: block; margin-bottom: 5px; font-weight: bold;">Name:</label>
<input type="text" id="imie" name="imie" placeholder="Enter name" style="width: 100%; padding: 8px; box-sizing: border-box;">
</div>
<div style="margin-bottom: 15px;">
<label for="email" style="display: block; margin-bottom: 5px; font-weight: bold;">E-mail:</label>
<input type="email" id="email" name="email" placeholder="address@example.com" style="width: 100%; padding: 8px; box-sizing: border-box;">
</div>
<button type="submit" style="background-color: #28a745; color: white; border: none; padding: 8px 15px; border-radius: 4px; cursor: pointer;">Send</button>
</form>
The browser will interpret this code as follows: