Go to main content
Bypass navigation bar HTML Reference HTML Tags HTML Tutorials
Bypass language selection
Bypass location bar

Location: Home > HTML Reference > HTML Tags > HTML select tag

Bypass main content

HTML select tag

Note: If you don't know what an element/tag is and/or how you must use it we recommend you to read our HTML tags and attributes tutorial that you can find in our HTML tutorials section.

Bypass main content


The HTML select element inserts a drop-down list of options in a document or form. This type of control presents a set of options (HTML option element), that can be arranged in groups (HTML optgroup element).

Essentially, this control is an alternative to radio buttons or checkboxes, depending on the value of the "multiple" attribute.

Note, that only selected options become succesful and can therefore be sent with the form when it's submitted.


<form action="example.php">
<optgroup label="Server-side languages">
<optgroup label="Client-side languages">


id (name)

The "id" attribute assigns an identifier to the associated element. This identifier must be unique in the document and can be used to refer to that element in other instances (e.g., from client-side scripts).

<p id="paragraph1">This is the first paragraph, named "paragraph1". To dynamically change its properties use this identifier.</p>

class (cdata)

The "class" attribute assigns a class name (or a list of class names separated by spaces) to the container element. It's used together with style sheets and tells the browser the class (or classes) to which the element is associated with.

A class gives presentational attributes to elements (read more at the Cascading Style Sheets tutorial).

<p class="references">This article is based on the book "Wind in the trees" by Jhon L. Brooks</p>
<p class="references important">This article is based on the book "Wind in the trees" by Jhon L. Brooks... and is more important than the one before.</p>

style (style)

This attribute is used to define presentational attributes for the containing element, and its value should be composed by style sheets properties. Although, in some cases, it can become useful, a better practice is to place presentational attributes in external files, relating them to elements with the "class" attribute. This way you keep the semantic and presentational parts of your document separated.

You can find more information about presentational attributes at the Cascading Style Sheets tutorial.

<p style="color: #0000FF; font-size: 12pt">This is a paragraph with a defined style.</p>
<p>And this is another text without style.</p>

title (text)

The purpose of this attribute is to provide a title for the element. Its value must be a short and accurate description of the element. Browsers usually render it as a "tool tip" when the user puts the mouse pointer over the element for a small period of time.

<a title="HTMLQuick.com" href="http://www.htmlquick.com">HTML code</a>

lang (langcode)

Specifies the language of an element's content. The default value in "unknown".

When writing XHTML 1.0 documents, the attribute used to specify the language of an elements is "xml:lang". For forward and backward compatibility both attributes can be used simultaneously like in the example below. Note, that in XHTML 1.1 the "lang" attribute has been completely replaced by "xml:lang" and its use is no longer valid.

<p lang="en" xml:lang="en">This is a paragraph in english.</p>
<p lang="es" xml:lang="es">Este es un párrafo en español.</p>


This attribute indicates the direction in which the texts of the element must be read. This includes content, attribute values and tables. It has two possible values that are case-insensitive:

  • RTL: Right to left.
  • LTR: Left to right.
<q lang="he" dir="rtl">...an Hebrew quotation...</q>

name (cdata)

Assigns a name to the element, that will be used to identify it by the processing agent when the form is sent.

<select name="favoritepet">


Users are unable to change the control's content when this attribute is present. Besides, the control can't receive focus and its data isn't sent with the form.

Browsers usually render disabled controls as they're faded, with a set of gray colors.

Remember that in XHTML, boolean attributes must take their own names as value (e.g., attr_name="attr_name").

<select disabled="disabled">

tabindex (number)

Specifies the position of this element in the tabbing order. The tabbing order defines a sequence with all the elements than can receive the focus. Users can navigate this sequence via keyboard (usually with the "tab" key).

First name: <input type="text" name="firstname" tabindex="1" />
Last name: <input type="text" name="lastname" tabindex="2" />
Phone number: <input type="text" name="phonenumber" tabindex="3" />

size (number)

When the control is displayed as a scrolled list box, this attribute sepcifies the height of that box in number of lines.

The decission of showing this control as a scrolled list box or not is left to the user agent. Most user agents display this control as a drop-down list unless the "multiple" attribute is present or a size greater than one has been specified.

<select size="3">


When this boolean attribute is present the user can pick more than one option by holding down the CTRL key while selecting. When absent, only one option can be selected.

Browsers usually render the control as a scrolled list box, instead of a drop-down menu, when this attribute is present.

Remember that in XHTML, boolean attributes must take their own names as value (e.g., attr_name="attr_name").

<select multiple="multiple">


  • onfocus
  • onblur
  • onchange
  • onclick
  • ondblclick
  • onmousedown
  • onmouseup
  • onmouseover
  • onmousemove
  • onmouseout
  • onkeypress
  • onkeydown
  • onkeyup

See a complete list and information about events in HTML

Diseño y desarrollo: Latitud29.com

Links and logos|Contact|Beyond HTML|Tools and resources|Sitemap|Webmaster|Donate