CSS Make Image Black and White: Practical Grayscale Examples
If you searched for css make image black and white, the core answer is simple: use the CSS filter property with grayscale(100%). This turns the rendered image into grayscale without changing the original image file.
This guide covers real CSS examples, hover interactions, background image patterns, Tailwind CSS utilities, browser behavior, accessibility considerations, and when to use an actual image converter instead of a CSS-only effect.
Basic CSS Grayscale
The simplest way to make image black and white CSS-style is:
.bw-image {
filter: grayscale(100%);
}
Apply it to an image:
<img class="bw-image" src="/photos/portrait.jpg" alt="Portrait in grayscale" />
grayscale(100%) removes the visible color from the rendered image. The original file remains unchanged, which is useful when you want the same asset to appear in color in one place and black and white in another.
Use Partial Grayscale
You do not have to use the full effect. Any value between 0% and 100% is valid.
.slightly-muted {
filter: grayscale(45%);
}
.fully-black-and-white {
filter: grayscale(100%);
}
Partial grayscale is useful for card grids, inactive states, editorial layouts, and image galleries where color should be reduced but not completely removed.
Hover Effect: Black and White to Color
A common pattern is to show images in black and white by default, then reveal color on hover.
.gallery-image {
filter: grayscale(100%);
transition: filter 200ms ease;
}
.gallery-image:hover,
.gallery-image:focus-visible {
filter: grayscale(0%);
}
<a href="/gallery" class="gallery-card">
<img class="gallery-image" src="/photos/city.jpg" alt="City street at night" />
</a>
This works well for portfolio grids, team cards, product previews, and blog thumbnails. The :focus-visible selector helps keyboard users receive a similar state change when the image is inside a focusable link or button.
If you need a permanent downloaded version instead of a CSS display effect, use the black and white image maker and export a real grayscale file.
Hover Effect: Color to Black and White
You can also do the reverse: keep the image in color normally and convert it on hover.
.product-image {
filter: grayscale(0%);
transition: filter 180ms ease;
}
.product-card:hover .product-image {
filter: grayscale(100%);
}
This can create a subtle editorial effect, but use it carefully. For ecommerce and accessibility, users should still be able to understand the product without relying on hover-only behavior.
Background Image Grayscale
CSS filters apply to the element and its rendered contents. For a background image, put the background on a pseudo-element and apply the filter there.
.hero {
position: relative;
min-height: 420px;
overflow: hidden;
}
.hero::before {
content: "";
position: absolute;
inset: 0;
background-image: url("/images/header-photo.jpg");
background-size: cover;
background-position: center;
filter: grayscale(100%);
z-index: 0;
}
.hero-content {
position: relative;
z-index: 1;
}
This keeps the filter on the visual layer while the text stays sharp and unaffected. Avoid putting filter: grayscale(100%) directly on a parent that contains text, buttons, or icons unless you want everything inside that parent to become grayscale.
Add Contrast After Grayscale
Some images look flat after grayscale conversion. CSS lets you combine filter functions:
.bw-contrast {
filter: grayscale(100%) contrast(1.15);
}
You can also adjust brightness:
.bw-muted {
filter: grayscale(100%) brightness(0.92) contrast(1.08);
}
Keep these values subtle. Heavy contrast can destroy detail in faces, clouds, fabric, and product photos.
Tailwind CSS Grayscale
Tailwind CSS includes filter utilities for grayscale effects.
<img
class="grayscale"
src="/photos/profile.jpg"
alt="Profile photo"
/>
For a hover reveal:
<img
class="grayscale transition duration-200 hover:grayscale-0"
src="/photos/project.jpg"
alt="Project preview"
/>
For responsive usage:
<img
class="grayscale md:grayscale-0"
src="/photos/banner.jpg"
alt="Banner image"
/>
If your Tailwind setup supports arbitrary filter values, you can combine grayscale with contrast:
<img
class="filter grayscale contrast-110"
src="/photos/editorial.jpg"
alt="Editorial portrait"
/>
The exact utility availability depends on your Tailwind version and configuration, so check your project's generated classes if a utility does not apply.
SVG and Icon Images
The same CSS filter can work on SVGs and image-based icons:
.partner-logo {
filter: grayscale(100%);
opacity: 0.8;
}
.partner-logo:hover {
filter: grayscale(0%);
opacity: 1;
}
For inline SVG icons, it is usually better to control fill, stroke, or currentColor directly. Use filters mainly for raster images, external SVG files, logos from partners, or content images.
Accessibility Notes
Black and white effects can improve focus, but they can also remove important information. Do not use grayscale as the only way to communicate disabled, active, selected, warning, or success states.
Use a second cue:
- Text labels.
- Icons.
- Borders.
- Patterns.
- Clear button states.
- Proper
aria-disabledor native disabled attributes when relevant.
Also check contrast after applying grayscale. A colorful image behind text may become too light or too busy once converted. If text sits on top of the image, add an overlay or choose a quieter crop.
Performance Notes
CSS filters are convenient, but they are still visual effects applied by the browser. A few grayscale images are usually fine. Large full-screen filtered backgrounds, animated filters, and long image grids can be heavier.
Use these practices:
- Apply filters to the image itself, not a huge parent container.
- Avoid animating many filtered images at the same time.
- Use appropriately sized image files.
- Prefer a pre-converted asset for large hero backgrounds that always appear black and white.
- Test on mobile if the page has many filtered images.
If the image is always meant to be black and white, a real converted file can be simpler and faster. You can create one with Make an Image Black and White or the main converter.
CSS vs Real Image Conversion
| Need | Best approach |
|---|---|
| Temporary visual effect on a website | CSS filter: grayscale(100%) |
| Hover from black and white to color | CSS filter with transition |
| Downloadable black and white file | Black and White Image Maker |
| Photo editing before upload | Make Photo Black and White |
| General how-to workflow | How to Make a Picture Black and White |
CSS is best when you want presentation control. A converter is best when you need the actual image file to become black and white.
Related Tutorials
For non-code workflows, see:
- How to Convert an Image to Black and White
- How to Make an Image Black and White in Photoshop
- How to Make an Image Black and White in Illustrator
FAQ
How do I make an image black and white in CSS?
Use filter: grayscale(100%); on the image element. This changes how the image is rendered in the browser without editing the original file.
What is the difference between css make image black and white and editing the file?
CSS changes the display effect only. Editing or converting the image creates a new black and white file that can be downloaded, shared, uploaded, or used outside the web page.
Can I make a background image black and white with CSS?
Yes. The cleanest pattern is to place the background image on a pseudo-element and apply filter: grayscale(100%) to that pseudo-element so text and buttons are not affected.
Does CSS grayscale hurt performance?
A small number of filtered images is usually fine. Performance can become a concern with many large filtered images, animated filters, or full-screen effects on mobile devices.
Conclusion
The practical css make image black and white solution is filter: grayscale(100%);. Use it for display effects, hover states, background treatments, and quick design variations. When you need a real downloadable grayscale file, convert the image with a dedicated tool like MakeImageBlackAndWhite.com instead of relying on CSS alone.