()
Line 28: Line 28:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
<label for="pet-select">Choose a pet:</label>
 
<select name="pets" id="pet-select">
 
    <option value="">--Please choose an option--</option>
 
    <option value="dog">Dog</option>
 
    <option value="cat">Cat</option>
 
    <option value="hamster">Hamster</option>
 
    <option value="parrot">Parrot</option>
 
    <option value="spider">Spider</option>
 
    <option value="goldfish">Goldfish</option>
 
</select>
 
 
or use the compliant HTML version :
 
 
<syntaxhighlight lang="html">
 
<label for="pet-select">Choose a pet:</label>
 
<select name="pets" id="pet-select">
 
    <option value="">--Please choose an option--</option>
 
    <option value="dog">Dog</option>
 
    <option value="cat">Cat</option>
 
    <option value="hamster">Hamster</option>
 
    <option value="parrot">Parrot</option>
 
    <option value="spider">Spider</option>
 
    <option value="goldfish">Goldfish</option>
 
</select>
 
</syntaxhighlight>
 
  
 
<label for="pet-select">Choose a pet:</label>
 
<label for="pet-select">Choose a pet:</label>

Revision as of 15:45, 4 January 2023

Name

option

Type

input

Synopsis

How to render an option input field. Mostly used within the input select fields.

Description

The < option > HTML element is used to define an item contained in a < select >, an < optgroup >, or a < datalist > element. As such, < option > can represent menu items in popups and other lists of items in an HTML document.

Parameters

input type="option". All valid HTML5 attributes are supported. There is one specific FlexForm parameter nohtmldecode. By default all values of an option input will be html decoded to get rid of special characters. To turn this off just add nohtmldecode as an argument to the option field.


Example

Using options with select:

<label for="pet-select">Choose a pet:</label>
<select name="pets" id="pet-select">
    <option value="">--Please choose an option--</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
    <option value="hamster">Hamster</option>
    <option value="parrot">Parrot</option>
    <option value="spider">Spider</option>
    <option value="goldfish">Goldfish</option>
</select>


Note

See also input/select from the menu on the right

Links

See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option for all the details.