HTML tag to create single or multiple selection menus
All major browsers support the
select element creates single-select or multiple-select menus.
Tip: The select element is a form control that can be used to accept user input in a form.
Properties
New: New attributes in HTML5.
Property | Value | Description |
---|---|---|
autofocus(5) | autofocus | Specifies that the text area automatically gains focus after the page loads. |
disabled | disabled | Provision to disable this dropdown list. |
form(5) | form_id | Specifies one or more forms to which the text area belongs. |
multiple | multiple | Multiple options can be selected. |
name | name | Specifies the name of the drop-down list. |
required(5) | required | Specifies that the text area is required. |
size | number | Specifies the number of visible options in the drop-down list. |
<html> <body> <form> <<span style="color: #0000ff;">select</span> name=<span style="color: #800000;">"</span><span style="color: #800000;">cars</span><span style="color: #800000;">"</span>> <option value=<span style="color: #800000;">"</span><span style="color: #800000;">volvo</span><span style="color: #800000;">"</span>>Volvo</option> <option value=<span style="color: #800000;">"</span><span style="color: #800000;">saab</span><span style="color: #800000;">"</span>>Saab</option> <option value=<span style="color: #800000;">"</span><span style="color: #800000;">fiat</span><span style="color: #800000;">"</span>>Fiat</option> <option value=<span style="color: #800000;">"</span><span style="color: #800000;">audi</span><span style="color: #800000;">"</span>>Audi</option> </<span style="color: #0000ff;">select</span>> </form> </body> </html>
- This example demonstrates how to create a simple drop-down list with pre-selected values. (Translator’s Note: Preselected values refer to pre-specified preferences.)
<html> <body> <form> <<span style="color: #0000ff;">select</span> name=<span style="color: #800000;">"</span><span style="color: #800000;">cars</span><span style="color: #800000;">"</span>> <option value=<span style="color: #800000;">"</span><span style="color: #800000;">volvo</span><span style="color: #800000;">"</span>>Volvo</option> <option value=<span style="color: #800000;">"</span><span style="color: #800000;">saab</span><span style="color: #800000;">"</span>>Saab</option> <option value=<span style="color: #800000;">"</span><span style="color: #800000;">fiat</span><span style="color: #800000;">"</span> selected=<span style="color: #800000;">"</span><span style="color: #800000;">selected</span><span style="color: #800000;">"</span>>Fiat</option> <option value=<span style="color: #800000;">"</span><span style="color: #800000;">audi</span><span style="color: #800000;">"</span>>Audi</option> </<span style="color: #0000ff;">select</span>> </form> </body> </html>
Attachment: Select object
Select object represents a drop-down list in an HTML form.
In an HTML form, every time the
You can access a Select object by looping through the form's elements[] array, or using document.getElementById().
Select object collection
Collection | Description |
---|---|
options[] | Returns an array containing all options in the dropdown list. |
Select object properties
Property | Description |
---|---|
disabled | Sets or returns whether the dropdown should be disabled. |
form | Returns a reference to the form containing the dropdown list. |
id | Set or return the id of the drop-down list. |
length | Returns the number of options in the drop-down list. |
multiple | Set or return whether to select multiple items. |
name | Set or return the name of the drop-down list. |
selectedIndex | Set or return the index number of the selected item in the drop-down list. |
size | Set or return the number of visible rows in the dropdown list. |
tabIndex | Set or return the tab key control order of the drop-down list. |
type | Returns the form type of the drop-down list. |
Standard properties
Property | Description |
---|---|
className | Sets or returns the class attribute of an element. |
dir | Set or return the direction of text. |
lang | Set or return the language code of the element. |
title | Sets or returns the element's title attribute. |
Select object method
Method | Description |
---|---|
add() | Add an option to the dropdown list. |
blur() | Remove focus from dropdown list. |
focus() | Set focus on dropdown list. |
remove() | Remove an option from the dropdown list. |
Select object event handle
Event handle | Description |
---|---|
onchange | Event handler called when the selection is changed. |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.
