Favorites

image() CSS Function

image()
CSS FunctionThis function is not supported by modern browsers.
Updated 21st November 2026

The image() function references an image with extra features such as fallbacks, image fragments and plain color images. It has very little browser support.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

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

Demo Code
HTML Code
<div class="demo-element"></div>
CSS Code
.demo-element {
	width: 280px;
	height: 170px;
	background-color: #e7ecff;
	border: 2px solid #4361ee;
	background-image: image(#f72585);
}

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

<div class="wrap">
<h1>CSS image() examples</h1>
<div class="grid">
<div class="card">
<div class="box solid">image(#2563eb)</div>
<div class="label">background-image: image(#2563eb)</div>
</div>
<div class="card">
<div class="box fallback">fallback color</div>
<div class="label">image("missing-file.jpg", #16a34a)</div>
</div>
</div>
<div class="status"></div>
</div>
/* Base demo layout */
* { box-sizing: border-box; }

body {
margin: 24px;
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
background: #f5f7fb;
color: #102a43;
}

.wrap {
max-width: 860px;
margin: 0 auto;
}

h1 {
font-size: 20px;
margin: 0 0 16px;
}

.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 16px;
}

.card {
background: #fff;
border-radius: 12px;
padding: 16px;
box-shadow: 0 6px 18px rgba(16, 42, 67, 0.08);
}

.label {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
font-size: 12px;
color: #486581;
margin-top: 10px;
word-break: break-word;
}

.note {
font-size: 13px;
color: #486581;
margin-top: 14px;
}

/* image() examples */
.box {
height: 120px;
border-radius: 10px;
display: grid;
place-items: center;
color: #fff;
font-weight: 700;
/* fallback for browsers without image() support */
background-color: #334155;
}

/* These declarations are ignored where image() is not supported */
.solid { background-image: image(#2563eb); }
.fallback { background-image: image("missing-file.jpg", #16a34a); }

.status {
margin-top: 16px;
padding: 10px 14px;
border-radius: 8px;
background: #fef3c7;
font-size: 13px;
}

.status::after { content: "image() is not supported in this browser, so the gray fallback is shown."; }

@supports (background-image: image(red)) {
.status { background: #dcfce7; }
.status::after { content: "image() is supported in this browser."; }
}
Open in editor

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.

This function is not supported by modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.