Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Filters, Masks and Shapes

The image-rendering property

Reference for the CSS image-rendering property: choose how the browser scales images up or down, including pixelated and crisp-edges for pixel art.

When a browser draws an image at a size different from its natural size, it has to guess the in-between pixels. By default it smooths the result, which looks good for photos but turns pixel art, QR codes and tiny icons into a blur. The image-rendering property is a hint about which scaling algorithm to prefer.

It applies to images of all kinds: <img>, <canvas>, <video>, and CSS background and border images.

CSS
.pixel-art {
  image-rendering: pixelated;
}

Try it

Smooth versus pixelated scaling

Both canvases are only 8 by 8 pixels and are enlarged to 128 by 128 by CSS. The left one is interpolated and looks smudged; the right one keeps hard square pixels.

Syntax

CSS
image-rendering: auto | smooth | high-quality | crisp-edges | pixelated;
Initial value auto
Applies to All elements (affects the images they draw)
Inherited Yes
Animatable No
Computed value As specified

Values

Value Description
auto The browser's default scaling, normally smooth interpolation.
smooth Asks for smooth scaling that keeps the image's look, similar to auto in practice.
high-quality Prefers quality over speed; may be slower. Often behaves like auto.
crisp-edges Scales so that edges and contrast are preserved, without smoothing colors. The exact algorithm depends on the browser.
pixelated Uses nearest-neighbor scaling when enlarging, so every source pixel becomes a sharp block.

Usage notes

  • It is only a hint. The specification lets browsers pick the algorithm, so crisp-edges and the smooth values do not look identical everywhere. pixelated is the most predictable choice for pixel art.
  • Only enlarging changes. Shrinking an image uses its own filtering; pixelated mostly affects upscaling.
  • Good fits: pixel art, sprites, QR codes, barcodes and screenshots shown at integer multiples of their size.
  • Bad fits: photographs. Hard blocks make them look broken.
  • Vector images (SVG) have no pixels to scale, so the property does nothing for them.
  • Canvas. For <canvas> content you drew yourself, you can also turn off smoothing in script with ctx.imageSmoothingEnabled = false.
  • Inheritance. Because the property is inherited, you can set it once on a container to cover every image inside it.

Browser support

auto and pixelated work in all current browsers. crisp-edges, smooth and high-quality are handled inconsistently, so check a compatibility table before relying on them, and treat them as hints.