Input Types
HTML input type="color"
Choose a color. A conventional six-digit hexadecimal value is a portable example; newer color options vary by browser. Use the value rather than the picker presentation; newer alpha and color-space attributes need separate support checks. Use only attributes applicable to this input state; the browser ignores or rejects unrelated constraints. Validate submitted data on the server.
Formal Syntax & Structure
html syntaxhtml
<input type="color">Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| type | literal color | Selects the color input state. |
| name | string | Provides an element-specific name: a form field key, radio group name, named frame, metadata key, slot name or other defined purpose. Its meaning depends on the element; it is not a unique DOM identifier. |
| disabled | boolean | Disables supported controls or elements. Disabled form controls are generally not focusable, validated or submitted. The exact effect depends on the element; disabled="false" still disables. |
| form | form element ID | Associates an eligible control with a form elsewhere in the same document, overriding an ancestor form where applicable. Does not automatically associate descendants of a fieldset. |
| value | element-dependent text or number | Default value or submitted value depending on type. A file input cannot be prefilled with a path. |
| list | datalist ID | Associates a supported input with a datalist of suggestions. It does not restrict the input to the listed values; use select when a closed set is required. |
| alpha | boolean | Requests alpha-channel support in a color input. This is a newer feature; do not assume every picker or browser handles transparency. |
| colorspace | enumerated: limited-srgb, display-p3 | Selects the color-space mode for a color input where supported. Use a conventional sRGB hex color when broad interoperability matters. |
Return Value
HTMLInputElement
Void form-associated element; no child content. The DOM value and form-submission behavior depend on the input state.
Working Example
Example Snippethtml
<label> Theme color <input type="color" name="color" value="#336699"></label>