Blog

HTML Aspect: choose | Envato Tuts+

The HTML choose ingredient is the basic dropdown most frequently seen in kinds. It permits customers to pick one thing from a set of choices. A number of choices will be chosen however customers are most frequently required to decide on one possibility per choose subject.

Examples

Syntax

1 title=“title” required>
2 worth=“1”>John
3 worth=“2”>Jane
4 worth=“3”>Donald
5 worth=“4”>Chuck
6 worth=“5”>Leslie
7

A choose ingredient with the a number of attribute enabled (true) permits for a number of choices to submit with a kind submission.

1 a number of title=“title” required>
2 worth=“1”>John
3 worth=“2”>Jane
4 worth=“3”>Donald
5 worth=“4”>Chuck
6 worth=“5”>Leslie
7

Outcome

Browser Help

The choose ingredient is supported in all trendy browsers. Learn extra on caniuse.com. 

Browsers show choose parts in another way, relying on their rendering engine. Check out this instance which exhibits the identical choose ingredient in Google Chrome (powered by Blink), Firefox (powered by Quantum), and Safari (powered by WebKit). 

select elements rendered by different browsersselect elements rendered by different browsers
All browsers listed below are on MacOS

Attributes

A choose ingredient helps World Attributes in HTML. World Attributes are widespread to all HTML parts and can be utilized on all of them (although they might not have a lot of an impact on a few of them).

Along with international attributes the choose ingredient has a bunch of different attributes:

  • autocomplete: Hit for a kind to autofill.
  • disabled: Whether or not or not the shape management is disabled.
  • kind: Associates the choose with a kind ingredient.
  • a number of: Whether or not or to not permit a number of values.
  • title: The title of the ingredient to make use of for kind submissions or by way of the shape.parts API.
  • required: Whether or not the choose is required for kind submission.
  • dimension: Measurement of the choose.

Content material

The choose ingredient helps zero or extra possibility, optgroup, and script-supporting parts.

If choosing a price is elective, you would possibly wish to embrace an empty3 worth=“2”>Jane4 worth=“3”>Donald5


6 worth=“4”>Chuck7 worth=“5”>Leslie8


9 worth=“6”>Ahmed10 worth=“7”>Coraline11

preview of a select element with hr elementspreview of a select element with hr elementspreview of a select element with hr elements
Right here’s how that appears 👆

Right here’s a dwell demo, however for those who’re unable to see the


parts in your browser, strive Safari Know-how Preview.

  • The elsewhere.
  • The