Thanks to visit codestin.com
Credit goes to www.cssportal.com

CSS Portal

CSS image-rendering Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The image-rendering CSS property controls how the user agent resamples bitmap images when they are scaled, transformed, or otherwise displayed at a resolution different from their intrinsic pixel grid. It determines the algorithm used to convert source pixels into the pixels of the output device, which affects whether an image appears smooth and blended or crisp and blocky when enlarged, reduced, or rendered at fractional device pixels. This property is relevant whenever an image is painted at a size that does not match its natural dimensions - for example when an image is stretched to fill a layout area or drawn at fractional CSS pixels.

Because the property influences sampling and interpolation, it has a direct effect on perceived sharpness, texture, and aliasing. Choosing a rendering mode that favors sharpness preserves hard edges and the rectangular shape of original pixels, which is often desired for pixel-art, icons, and UI sprites where clarity of individual pixels is important. Conversely, a mode that favors smooth interpolation blends neighboring pixels, which reduces jagged edges and artifacts and is often preferred for photographs and high-resolution artwork. The runtime decision also interacts with device pixel ratios and subpixel positioning: on high-DPI screens there is less need to aggressively preserve pixel blocks, whereas on low-DPI displays or when intentionally scaling by integer factors, a pixel-preserving approach can make images appear more faithful.

The visual outcome of the property interacts with other layout and rendering rules. For example, when an image is fitted into a replaced element or container, the element’s sizing behavior affects how much scaling happens; properties that control how an image fills its box, such as object-fit, determine the scale factor that will then be subject to the chosen sampling strategy. Likewise, scaling applied via transforms or by changing the element’s size is combined with the image-rendering decision; see transform for how CSS transforms can change an image’s rendered size without changing its intrinsic dimensions. Background images and their placement also interact with sampling, so when using background images it’s useful to consider background-size because that property controls the painting size that image-rendering will then process.

Practical considerations include performance and visual consistency. Some resampling approaches are more computationally expensive than others, and using high-quality interpolation for many large images can increase painting cost and GPU/CPU usage; conversely, pixel-preserving sampling is cheap but can produce visual artifacts when the scale is not an integer. Also bear in mind accessibility and readability: text or iconography represented as bitmaps can become illegible if scaled with inappropriate sampling, whereas photographs can look noisy or posterized if pixel-blocking is applied indiscriminately. When designing, test on representative content and target devices to ensure the chosen rendering behavior aligns with both aesthetic goals and performance constraints.

Definition

Initial value
auto
Applies to
all elements
Inherited
yes
Computed value
as specified
Animatable
yes
JavaScript syntax
object.style.imageRendering

Interactive Demo

Syntax

image-rendering: auto | crisp-edges | pixelated

Values

  • autoThe scaling algorithm is UA dependent. Since version 1.9 (Firefox 3.0), Gecko uses bilinear resampling (high quality).
  • crisp-edgesThe image is scaled with an algorithm that preserves contrast and edges in the image. Generally intended for images such as pixel art or line drawings, no blurring or color smoothing occurs.
  • pixelatedThe image is scaled with the "nearest neighbor" or similar algorithm, preserving a "pixelated" look as the image changes in size.

Example

<div class='wrap'>
<h2>image-rendering demo</h2>
<div class='row'>
<figure>
<img class='smooth' src='https://picsum.photos/200' alt='small pattern'>
<figcaption>Smooth (default)</figcaption>
</figure>

<figure>
<img class='pixelated' src='https://picsum.photos/200' alt='small pattern'>
<figcaption>Pixelated</figcaption>
</figure>
</div>
</div>
/* Layout and typography */
.wrap {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  padding: 20px;
  max-width: 760px;
  margin: 0 auto;
}

.row {
  display: flex;
  gap: 24px;
  align-items: center;
}

figure {
  margin: 0;
  text-align: center;
}

figcaption {
  margin-top: 8px;
  font-size: 14px;
  color: #333;
}

/* Image sizing and default rendering */
img {
  width: 320px;
  height: 320px;
  display: block;
  margin: 0 auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  image-rendering: auto; /* default behavior */
}

/* Pixelated rendering with fallbacks for different browsers */
img.pixelated {
  /* Older/WebKit heuristics */
  image-rendering: -webkit-optimize-contrast;
  /* Firefox */
  image-rendering: -moz-crisp-edges;
  /* Opera */
  image-rendering: -o-crisp-edges;
  /* Newer standard values */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  /* IE (legacy) nearest-neighbor scaling */
  -ms-interpolation-mode: nearest-neighbor;
}

Browser Support

The following information will show you the current browser support for the CSS image-rendering property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!