CKTIS / CSS
image(): a generated image and draft fallback syntax
Create an image value from a color; distinguish that working form from newer image-source syntax.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
background-image: image(rgb(220 40 10));The image() function returns an image, not a color. A solid-color image can fill a background layer and be combined with other layers. Unlike a URL image it has no natural width or height, so its concrete dimensions come from the context in which it is painted.
CSS Images Level 5 also specifies image sources, directional annotations and a fallback color. These draft forms must be checked separately: support for image(red) does not prove support for image(url(...), red). A preceding, widely supported background declaration remains useful when a browser rejects a newer value.
The example first installs a gradient fallback and then tries image(rgb(220 40 10)). Chromium 157 accepts the color form and paints the sampled pixel 220,40,10, but rejects the tested URL-with-fallback form. CSS.supports() checks syntax support; it does not download an image or prove that an arbitrary URL can be decoded.
Examples
const sample=async style=>{const svg='<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8"><rect width="8" height="8" fill="white"/><foreignObject width="8" height="8"><div xmlns="http://www.w3.org/1999/xhtml" style="width:8px;height:8px;'+style.replaceAll('&','&').replaceAll('"','"')+'"></div></foreignObject></svg>';const image=new Image();image.src='data:image/svg+xml;charset=utf-8,'+encodeURIComponent(svg);await image.decode();const canvas=document.createElement('canvas');canvas.width=canvas.height=8;const context=canvas.getContext('2d');context.drawImage(image,0,0);return [...context.getImageData(4,4,1,1).data].slice(0,3).join(',')};
const fallback='linear-gradient(rgb(20 40 60), rgb(20 40 60))';
const value='image(rgb(220 40 10))';
const element=document.createElement('div');
element.style.backgroundImage=fallback;
element.style.backgroundImage=value;
document.body.append(element);
const pixel=await sample('background-image:'+value);
const urlForm=CSS.supports('background-image',"image(url('missing.png'), blue)");
console.log('supported='+CSS.supports('background-image',value)+'; pixel='+pixel+'; url-form='+urlForm+'; applied='+getComputedStyle(element).backgroundImage);Result
supported=true; pixel=220,40,10; url-form=false; applied=image(rgb(220, 40, 10))
The pixel confirms actual painting of the color form. The false URL-form result is an implementation limitation, not proof that the draft syntax is invalid.