HTML option Tag value Attribute Tutorial

In this section, we will learn what the value attribute is and how to use it.

What is value Attribute in HTML <option> Tag?

The value attribute is the value we set for an <option> element to be sent to a server.

The value we put within the opening and closing tags of an <option> element is the one that users will see. But the value we set for the `value` attribute is the one to be submitted to a server.

Note: if we don’t provide the `value` attribute for an <option> element, then its body value (the one between opening and closing tags) is the one to be sent to a server.

HTML value Attribute in <option> Tag Syntax:

<option value = “server-value”> </option>

<option> Tag value Attribute Values

The value we set for the `value` attribute is the one we want to send to a server if that <option> element was selected.

Example: using value attribute in HTML <option> tag

See the Pen using value attribute in HTML <option> tag by Omid Dehghan (@odehghan) on CodePen.

Facebook
Twitter
Pinterest
LinkedIn

Top Technologies