Input Color name Attribute

Definition and Usage

name Sets or returns the value of the name attribute of the color selector.

The HTML name attribute is used to identify form data after the form data is submitted to the server, or to reference form data on the client using JavaScript.

Note:Only form elements that have a name attribute will pass their values when submitting the form.

See also:

HTML Reference Manual:HTML <input> name Attribute

Example

Example 1

Get the name of the color selector:

var x = document.getElementById("myColor").name;

Try it yourself

Example 2

Change the name of the color selector:

document.getElementById("myColor").name = "newColorName";

Try it yourself

Syntax

Return the name attribute:

colorObject.name

Set the name attribute:

colorObject.name = name

Attribute value

Value Description
name Define the name of the color selector.

Technical Details

Return Value: A string value representing the name of the color selector.

Browser Support

The numbers in the table indicate the first browser version to fully support this attribute.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support

Note:The <input type="color"> element does not display any color selector in Internet Explorer and Safari.