HTML: option
The <option> element defines one choice inside a <select> or one suggestion inside a <datalist>.
What you will learn
- How visible text and value are used
- How to mark choices as selected or disabled
- How option differs between select and datalist
Minimal example
<select name="plan">
<option value="basic">Basic plan</option>
<option value="pro" selected>Pro plan</option>
</select>The visible text helps the user choose, while value is the data sent with the form. Keep the value stable even if the displayed wording changes.
Common mistakes
- Do not use an empty or unstable value when the server needs to identify the choice.
- Validate submitted values against the choices allowed for the current user.
- Use
disabledfor unavailable choices and explain why when helpful.