Yahoo India Web Search

Search results

  1. Learn how to use the HTML select tag to create a drop-down list in a form. See examples, attributes, browser support, and related pages.

    • Form

      W3Schools offers free online tutorials, references and...

    • Multiple

      For windows: Hold down the control (ctrl) button to select...

    • Required

      Learn how to use the required attribute of the HTML <select>...

  2. 4 days ago · Learn how to use the tag in HTML to create a drop-down list with options. See syntax, attributes, examples and supported browsers for this tag.

    • Overview
    • Try it
    • Attributes
    • Usage notes
    • Styling with CSS
    • Examples
    • Accessibility concerns

    The HTML element represents a control that provides a menu of options.

    The above example shows typical usage. It is given an id attribute to enable it to be associated with a for accessibility purposes, as well as a name attribute to represent the name of the associated data point submitted to the server. Each menu option is defined by an element nested inside the .

    Each element should have a value attribute containing the data value to submit to the server when that option is selected. If no value attribute is included, the value defaults to the text contained inside the element. You can include a selected attribute on an element to make it selected by default when the page first loads.

    The element has some unique attributes you can use to control it, such as multiple to specify whether multiple options can be selected, and size to specify how many options should be shown at once. It also accepts most of the general form input attributes such as required, disabled, autofocus, etc.

    You can further nest elements inside elements to create separate groups of options inside the dropdown. You can also include elements to create separators that add visual breaks between options.

    This element includes the global attributes.

    autocomplete

    A string providing a hint for a user agent's autocomplete feature. See The HTML autocomplete attribute for a complete list of values and details on how to use autocomplete.

    autofocus

    This Boolean attribute lets you specify that a form control should have input focus when the page loads. Only one form element in a document can have the autofocus attribute.

    disabled

    Selecting multiple options

    On a desktop computer, there are a number of ways to select multiple options in a element with a multiple attribute: Mouse users can hold the Ctrl, Command, or Shift keys (depending on what makes sense for your operating system) and then click multiple options to select/deselect them. Keyboard users can select multiple contiguous items by: •Focusing on the element (e.g. using Tab ). •Selecting an item at the top or bottom of the range they want to select using the Up and Down cursor keys to go up and down the options. •Holding down the Shift key and then using the Up and Down cursor keys to increase or decrease the range of items selected. Keyboard users can select multiple non-contiguous items by: •Focusing on the element (e.g. using Tab ). •Holding down the Ctrl key then using the Up and Down cursor keys to change the "focused" select option, i.e. the one that will be selected if you choose to do so. The "focused" select option is highlighted with a dotted outline, in the same way as a keyboard-focused link. •Pressing Space to select/deselect "focused" select options.

    The element is notoriously difficult to style productively with CSS. You can affect certain aspects like any element — for example, manipulating the box model, the displayed font, etc., and you can use the appearance property to remove the default system appearance.

    However, these properties don't produce a consistent result across browsers, and it is hard to do things like line different types of form element up with one another in a column. The element's internal structure is complex, and hard to control. If you want to get full control, you should consider using a library with good facilities for styling form widgets, or try rolling your own dropdown menu using non-semantic elements, JavaScript, and WAI-ARIA to provide semantics.

    For more useful information on styling , see:

    •Styling HTML forms

    •Advanced styling for HTML forms

    Also see the "Customizing select styles" example below for an example of you could attempt a simple styling.

    Basic select

    The following example creates a very simple dropdown menu, the second option of which is selected by default.

    Select with grouping options

    The following example creates a dropdown menu with grouping using and to make it easier for the user to understand the content in the dropdown.

    Advanced select with multiple features

    The follow example is more complex, showing off more features you can use on a element:

    The within a should be considered purely decorative, as they are currently not exposed within the accessibility tree and therefore not exposed to assistive technologies.

  3. Learn how to use the HTML tag to create a drop down list of options in a form. See the syntax, examples, attributes, and how to style the tag with CSS.

  4. May 22, 2024 · Learn how to create and customize HTML dropdowns using the tag and its attributes. See examples of basic, hover, multi-select and nested dropdowns with code and output.

  5. Sep 3, 2021 · You use the HTML select tag to create drop-down menus so that users can select the value they want. It is an instrumental feature in collecting data to be sent to a server. The select tag normally goes within a form element, with the items to choose from coded within another tag, <option> .

  6. People also ask

  7. HTML <select> tag is used to create dropdown lists in online forms. Users are able to choose one or more selections from a list of choices. Within the <select> tag, it is made up of <option> tags. For identification and form submission, attributes like name and id are needed.

  1. People also search for