HTML DOM Input Color name Property

HTMLWeb DevelopmentFront End Technology

The Input Color name property returns a string, which is the value of the input color name attribute. User can also set it to a new string.


Following is the syntax −

  • Returning string value
  • Setting name attribute to a string value = ‘String’


Let us see an example of Input Color name property −

 Live Demo

<!DOCTYPE html>
<title>Input Color Name</title>
<form id="formForColorsInput">
Color Picker: <input type="color" id="Color" name="primaryColor">
<button onclick="changeNameValue()">Change name value</button>
<div id="divDisplay"></div>
   var inputColor = document.getElementById("Color");
   var divDisplay = document.getElementById("divDisplay");
   divDisplay.textContent = 'Name of color input: ';
   function changeNameValue() {
      if( == 'primaryColor'){ = 'secondaryColor';
         divDisplay.textContent = 'Name of color input: ';


This will produce the following output −

Before clicking ‘Change name value’ button −

After clicking ‘Change name value’ button −

Updated on 30-Jul-2019 22:30:26