Change the color of a color picker:
The value property sets or returns the value of the value attribute of a color picker.
The value attribute specifies the color for the color picker.
Note: If nothing is specified, the default color is #000000 (black).
The value property is supported in all major browsers.
Note: The <input type="color"> element is not supported in Internet Explorer and Safari.
Return the value property:
Set the value property:
Value | Description |
---|---|
#hexvalue |
Specifies a color for the color picker. The value must be a hexadecimal (hex) value: 3 double digit numbers, starting with a # sign (like #FF8040). Note: Color keywords (like "red" or "blue") are not allowed. Note: Default color is #000000 (black). |
Return Value: | A String, representing a color |
---|
Get the color of a color picker:
The result of x will be:
An example that shows the difference between the defaultValue and value property:
HTML tutorial: HTML Colors
HTML tutorial: HTML Color Values (HEX)
HTML reference: HTML <input> value attribute