CSS
HTML
COMPONENTS
CODE HUB
CSS Grayscale Generator
Configuration
Grayscale
Class
Preview

Code
Learn to Code with Lara
Master programming concepts step-by-step with your interactive AI tutor. Lara explains complex logic, reviews your practice exercises, and helps you build a solid foundation in software development.
Interactive coding lessons tailored to your own pace.
Start learning with LaraCSS Grayscale Generator
In CSS, you can apply the grayscale effect to elements, such as images or text, using the filter property. The grayscale effect converts the colors of an element to shades of gray, giving it a black-and-white appearance.
Here's how you can apply the grayscale effect in CSS:
.grayscale-element {
filter: grayscale(100%);
}
in this example:
- The .grayscale-element class applies the grayscale effect to the element it targets.
- grayscale(100%) specifies that the element should be fully grayscale, meaning that all colors are converted to shades of gray.
Here's another example with partial grayscale:
.partial-grayscale-element {
filter: grayscale(50%);
}
In this case, the partial-grayscale-element class applies a 50% grayscale effect, allowing some color to show through.
The filter property can be used to apply various other visual effects as well, and it's a versatile tool for enhancing the appearance of elements on your web page. Keep in mind that browser support for the filter property may vary, so it's important to test the effect in different browsers to ensure compatibility.