Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Select Element | Forms
Ultimate HTML

Select ElementSelect Element

The <select> element is used to create a dropdown list of options for the user to choose from. It is typically used in forms where the user needs to choose from a predefined set of options. It is always used in conjunction with <option> elements. The <option> elements define the individual items in the dropdown list.

html

index.html

css

index.css

js

index.js

The <select> element also has several attributes that can be used to modify its behavior, including:

  • name - The name of the select element, used when submitting the form;
  • size - The number of visible options in the dropdown list;
  • multiple - If present, allows the user to select multiple options;
  • disabled - If present, disables the select element.

To divide a list into separate, unrelated groups, we can use the <optgroup> tag. The label attribute is used to assign a title to the group.

html

index.html

css

index.css

js

index.js

Note

By default, the first <option> is chosen in the list. If we want to change it, we can provide selected attribute to the any <option> element.

Everything was clear?

Section 5. Chapter 8

Select ElementSelect Element

The <select> element is used to create a dropdown list of options for the user to choose from. It is typically used in forms where the user needs to choose from a predefined set of options. It is always used in conjunction with <option> elements. The <option> elements define the individual items in the dropdown list.

html

index.html

css

index.css

js

index.js

The <select> element also has several attributes that can be used to modify its behavior, including:

  • name - The name of the select element, used when submitting the form;
  • size - The number of visible options in the dropdown list;
  • multiple - If present, allows the user to select multiple options;
  • disabled - If present, disables the select element.

To divide a list into separate, unrelated groups, we can use the <optgroup> tag. The label attribute is used to assign a title to the group.

html

index.html

css

index.css

js

index.js

Note

By default, the first <option> is chosen in the list. If we want to change it, we can provide selected attribute to the any <option> element.

Everything was clear?

Section 5. Chapter 8
some-alt