Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

colorspace: select a color input’s serialization space

Use wide-gamut color progressively and distinguish a standard rule from browser support.

Version: HTML Living Standard

Syntax

<input type="color" colorspace="display-p3">

For a color input, colorspace selects the space used to serialize its CSS color and hints at the desired picker interface. limited-srgb is the default, including for missing or invalid values, and limits sRGB components to eight bits. display-p3 selects Display P3 serialization. Transparency is controlled separately by alpha; choosing a wider gamut does not itself enable opacity editing.

The newer behavior is not universally implemented. Support for wide-gamut CSS colors elsewhere on the page does not prove support in this form control. Detect the colorSpace DOM capability and test value handling in the target browsers. Choose an explicit sRGB fallback when necessary and avoid silently describing that fallback as lossless preservation of a wide-gamut color.

Chromium 145 lacks the DOM capability in this test. The example therefore removes the unsupported setting and deliberately assigns a red sRGB hex value. The recorded result confirms the fallback path, not a working Display P3 picker. Engines implementing the feature can follow a different branch and serialize a different value.

Examples

<!doctype html><meta charset="utf-8">
<label>Color <input id="color" type="color" colorspace="display-p3" value="color(display-p3 1 0 0)"></label>
<output id="result"></output><script>
const field = document.querySelector('#color');
const supported = 'colorSpace' in field;
if (!supported) {
  field.removeAttribute('colorspace');
  field.value = '#ff0000'; // Deliberate sRGB fallback chosen by the application.
}
document.querySelector('#result').textContent = 'colorSpaceAPI=' + supported + '; value=' + field.value;
</script>

Result

colorSpaceAPI=false; value=#ff0000

This receipt proves the explicit fallback in the tested browser; it is not evidence of Display P3 picker support.

Sources