Want to display black and white photos without manually editing each one? With just a single line of CSS, you can apply a grayscale effect to any imageβgreat for portfolios, photography sites, galleries, and minimalist aesthetics.
β¨ The CSS Trick
Apply this to any image you want to desaturate:
.bw {
filter: grayscale(100%);
}`
And just like that, your image appears in black and white.
π― Add Hover to Reveal Full Color
Want to show the full-color version when the user hovers?
`.bw {
filter: grayscale(100%);
transition: filter 0.4s ease-in-out;
}
.bw:hover {
filter: grayscale(0%);
}`
This is perfect for hover effects on image galleries, product showcases, or photo collections.
π‘ Where You Can Use This
Online portfolios or photography websites
Preview images in black & white and reveal color on hover
Mood-driven layout design (e.g. minimalist or editorial-style pages)
UX designs where color conveys interactivity
ποΈ Bonus: Use It With Remote Images
This technique works with any image, even external ones. That means you can apply it to:
<img class="bw" src="https://yourdomain.com/images/foto-34.jpg" alt="Photo from your site">
If youβre running a photo site or free image library, this can also help highlight premium or featured content via color reveals.
β
Browser Support
Browser Support for filter: grayscale()
Chrome β
Full
Firefox β
Full
Safari β
Full
Edge (Chromium) β
Full
Internet Explorer β Not supported
You can add -webkit-filter as a fallback if you're targeting older versions of Safari.
π§ Whatβs Next?
If you like this trick, here are more CSS-only image effects worth exploring:
filter: sepia(100%) β Vintage photo look
filter: blur(5px) β Soft focus or loading effect
filter: brightness(1.4) contrast(1.1) β High-impact editorial styles
Combining filters for custom B&W styles with tone control

Top comments (0)