image() CSS Function
The image() function references an image with extra features such as fallbacks, image fragments and plain color images. It has very little browser support.
Description
The image() CSS function is a more powerful way to reference an image than url(). It is defined in CSS Images Module Level 4 and adds three abilities: you can mark an image as left-to-right or right-to-left so it is mirrored automatically in the opposite writing direction, you can refer to just a fragment (part) of an image, and you can provide a solid color that is used if the image fails to load or as an image in its own right.
The optional first argument, ltr or rtl, says which text direction the image was designed for. If the element's direction is the opposite, the browser flips the image horizontally, which is useful for arrows and other directional icons. The image source can be a URL string, optionally with a media fragment such as #xywh=0,0,32,32 to crop a sprite. If a <color> is given, it acts as a fallback when the image cannot be shown; if only a color is given, image() produces a solid-color image of that color, which can be layered like any other background image.
At the time of writing, no stable browser release supports image(). Chrome and Firefox have both announced plans to ship the simplest form, image(<color>), which creates a solid-color image with no natural size (equivalent to a one-color linear-gradient()). The direction tags, fragments and fallback forms are not planned yet. For now, use url() or image-set() in real projects and treat image() as a feature to watch.
/* Arrow icon mirrored automatically in right-to-left text */
.next::after {
content: image(ltr "arrow-right.svg");
}
/* Fallback color if the photo fails to load */
.hero {
background-image: image("hero.jpg", #334155);
}
/* A solid color layered under a pattern */
.panel {
background-image: url("dots.svg"), image(rgb(0 0 0 / 0.1));
}
Interactive Demo
Syntax
image() = image( <image-tags>? [ <image-src>? , <color>? ]! )
<image-tags> = ltr | rtl
<image-src> = [ <url> | <string> ]
Values
- <image-tags>Optional. ltr or rtl, the directionality the image was designed for. If the element's direction differs, the image is mirrored horizontally.
- <image-src>Optional. A <url> or <string> pointing to the image. It may include a media fragment, such as #xywh=x,y,w,h, to use only part of the image.
- <color>Optional. A color used as a fallback if the image cannot be loaded, or, when no source is given, as a solid-color image.
Example
Browser Support
The following information will show you the current browser support for the CSS image() function. Hover over a browser icon to see the version that first introduced support for this CSS function.
Desktop





Tablets & Mobile





