Forms

Defines a form container.

Common Attributes:

  • action: URL where the form data is sent.

  • method: HTTP method (get or post).

  • target: Where to display the response (_blank, _self, etc).

  • autocomplete: Turn autocomplete on/off.

<form action="/submit" method="post"></form>

Generic input field. Type changes its behavior.

Common Attributes:

  • type: text, password, email, number, checkbox, radio, submit, file, etc.

  • name: Name of the field (used in backend).

  • value: Default value.

  • placeholder: Hint inside the field.

  • required: Makes field required.

  • readonly: Non-editable.

  • disabled: Disabled field.

<input type="text" name="username" />

Defines a label for an input field. Should match id of input.

<label for="email">Email:</label>

Multiline text input.

<textarea name="message" rows="4" cols="30"></textarea>

Creates a dropdown list.

<select name="color">
  <option value="red">Red</option>
</select>

Defines each item in the dropdown.

<option value="green">Green</option>

Groups related options in a dropdown.

<optgroup label="Fruits">
  <option>Apple</option>
</optgroup>

Creates a button.

type values:

  • submit: Submits the form.

  • reset: Resets the form.

  • button: Normal button, does nothing unless scripted.

<button type="submit">Send</button>

Last updated