Open In App

HTML <option> value Attribute

Last Updated : 13 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

HTML <option> value attribute determines the data sent to the server upon form submission, while the text content represents the visible options in dropdown menus.

Syntax:

<option value = "value">

Attribute Value: It contains a single value that has to be sent to the server. 

HTML option value Attribute Example

Example: This example demonstrates the use of the option value attribute to retrieve and display the selected option’s value.

HTML
<!DOCTYPE html>
<html>

<body>
    <h2>HTML option value Attribute</h2>

    <strong>Sorting Algorithms:</strong>
    <select id="opt">
        <option value="quick">Quick sort</option>
        <option value="merge">Merge sort</option>
        <option value="insertion">Insertion sort</option>
    </select>
    <button type="submit">Click me!</button>

</body>
</html>

Output: After selecting the options available, the submit button can be used to send the data to the server.

HTML-Option-value_Attribute

HTML option value Attribute Example Output

Supported Browsers: The browsers supported by the value attribute in the option tag are listed below.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads