THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Input Color value Property

Input Color Object Reference Input Color Object

Example

Change the color of a color picker:

document.getElementById("myColor").value = "#FF8040";
Try it yourself »

Definition and Usage

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).


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The value property is supported in all major browsers.

Note: The <input type="color"> element is not supported in Internet Explorer and Safari.


Syntax

Return the value property:

colorObject.value

Set the value property:

colorObject.value=#hexvalue

Property Values

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).

Technical Details

Return Value: A String, representing a color

More Examples

Example

Get the color of a color picker:

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

The result of x will be:

#ff0080
Try it yourself »

Example

An example that shows the difference between the defaultValue and value property:

var x = document.getElementById("myColor");
var defaultVal = x.defaultValue;
var currentVal = x.value;
Try it yourself »

Related Pages

HTML tutorial: HTML Colors

HTML tutorial: HTML Color Values (HEX)

HTML reference: HTML <input> value attribute


Input Color Object Reference Input Color Object