<select>: The SELECT Element

Last updated: 2026-10-13

<select>The SELECT Element

A drop-down control that lets the user pick one or more values from a preset list, usually submitted with a form.

CategoryForms
Content ModelFlow content
Allowed ParentsAny element that accepts flow content
Content TagYes — requires closing </select> tag
StatusStandard

📝 Syntax

<select name="fruit">
  <option value="apple">Apple</option>
  <option value="banana">Banana</option>
</select>

⚙️ Attributes

This element supports the global attributes plus the following:

AttributeValueDescription
nameField name sent to the server.
multipleAllow selecting multiple options.
requiredA value must be selected before submit.
disabledDisables the whole control.
sizeNumber of visible rows (a list box when > 1).
autofocusAutomatically focused on page load.
formThe id of the associated form (can live outside it).

▶ Example

Edit the code below and see the live result in the playground:

🌐 Browser Support

Browser ChromeChrome EdgeEdge FirefoxFirefox SafariSafari OperaOpera
<select> ✓ v1 ✓ v12 ✓ v1 ✓ v1 ✓ v1
Supported in all major browsers
Tip: Use multiple for multi-select; for free typing combine input + datalist.

❓ FAQ

QHow do I set the default selected option in a select?
AAdd the selected attribute to the corresponding <option>: <option selected>Default</option>. Without it the first option is selected. You can also set select.value with JS to change the selection.
QCan select allow multiple selections?
AYes, with the multiple attribute: Ctrl/Cmd-click on desktop, though mobile support is awkward. A multi-select's name should be an array form (such as name='tags[]') so the backend receives multiple values. For long option lists, a checkbox group is friendlier.
QWhat if a select has too many options?
AGroup them with <optgroup> captions, or switch to <input list> plus <datalist> for a searchable suggestion field. The native select cannot be searched; beyond a few dozen options, use datalist or a third-party component.
More case studies coming soon — check back later.

📚 Related Tutorials

Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏