HTML select Tag name Attribute Tutorial

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

What is name Attribute in HTML <select> Tag?

The name attribute is used in an HTML <select> element to set a name for it.

This name could then be used in other languages like JavaScript and CSS to access the element and apply the necessary modifications.

Other than that, after the value of a dropdown list is sent to a server, that server also use this name to access the value of the target <select> element.

HTML name Attribute in <select> Tag Syntax:

<select name = “name”> </select>

<select> Tag name Attribute Values

The value we set for the `name` attribute can be any general or specific name. But you should always endeavor to use names associated with the purpose of the target element.

Example: using name attribute in HTML <select> tag

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

Leave a Reply