Input Color value attribute
Definition and Usage
value
Attribute sets or returns the value of the value attribute of the color selector.
The HTML value attribute specifies the color of the color selector.
Comments:If no content is specified, the default color is #000000 (black).
Related Pages
HTML Tutorial:HTML Colors
HTML Reference Manual:HTML <input> value Attribute
Instance
Example 1
Change the color of the color selector:
document.getElementById("myColor").value = "#FF8040";
Example 2
Get the color of the color selector:
var x = document.getElementById("myColor").value;
Example 3
An example showing the difference between the defaultValue and value attributes:
var x = document.getElementById("myColor"); var defaultVal = x.defaultValue; var currentVal = x.value;
Syntax
Return the value attribute:
colorObject.value
Set the value attribute:
colorObject.value = #hexvalue
Attribute value
Value | Description |
---|---|
#hexvalue |
Specifies the color of the color selector. This value must be a hexadecimal (hex) value: three two-digit numbers, starting with the # symbol (such as #FF8040). Note:Color keywords (such as "red" or "blue") are not allowed. Comments:The default color is #000000 (black). |
Technical Details
Return Value: | A string value representing the color. |
---|
Browser Support
The numbers in the table indicate the first browser version that fully supports 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.