The filter property processes an element's rendered pixels through operations such as grayscale or blur. It changes appearance after layout; it does not change the element's intrinsic content.
CSS filter effects: use image treatment without obscuring evidence
When to use it
A gallery of closed cases uses desaturated thumbnails to distinguish archived records from active ones. Keep a visible text state beside each thumbnail, since grayscale alone cannot communicate archival status. Do not apply blur to evidence that a reviewer must inspect; provide the original image through a proper detail view. The sample uses grayscale only on a decorative preview class and returns full color on keyboard focus within the card. A visual effect can create a new stacking context, so inspect overlays and positioned badges after adding it. Check the card with images disabled and in print. CSS filtering cannot redact sensitive information, because the underlying asset remains available and must be protected at the server boundary.
.case-card--archived .case-card__preview { filter: grayscale(80%); }
.case-card--archived:focus-within .case-card__preview { filter: none; }
.case-card__status { font-weight: 700; }Cost and verification
Filters may require extra painting or compositing, especially across many large images. Measure a gallery with realistic thumbnails before applying blur or stacked effects to every item. A simple grayscale filter on a small preview may be acceptable, but the benchmark must come from the target devices. The status text remains the primary information channel. Do not confuse a visual mask with a security control, and do not let an effect reduce the legibility of captions or focus indicators. If print output is official, inspect it without relying on color treatment.
Common Mistakes
- Do not use blur as data redaction.
- Do not convey archived status only through grayscale.
- Do not apply expensive filters to hundreds of full-resolution images without measurement.
Connected lessons
- CSS Property Decisions
- CSS object-fit and aspect ratio: crop a preview without distorting it
- CSS color and contrast: pair text with its real surface
- CSS stacking contexts: debug overlays without arbitrary z-index inflation
