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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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

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.

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.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

To achieve the effect of scattering and enlarging the surrounding images after clicking on the image, many web designs need to achieve an interactive effect: click on a certain image to make the surrounding...

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

The Y-axis position adaptive algorithm for web annotation function This article will explore how to implement annotation functions similar to Word documents, especially how to deal with the interval between annotations...
