When creating filter effects, the filter
or backdrop-filter
property is provided a space-separated list of filters. These filter effects are applied in the order in which they appear.
In this example, both magenta
drop shadow and 180deg
hue rotation are applied on the level-one heading. The example shows the effect when these filters are applied in different orders.
h1 {
color: midnightblue;
}
#hueFirst {
filter: hue-rotate(180deg) drop-shadow(3px 3px magenta);
}
#shadowFirst {
filter: drop-shadow(3px 3px magenta) hue-rotate(180deg);
}
The same filters are applied to both the lines of text but in a different order. In the first line, the hue of the text is altered before the shadow is applied, so the shadow is magenta
. In the second line, the drop shadow is added to the dark blue text, and then the hue of both the text and the shadow are altered.
No filter effect is applied to the third line to show the original effect as a comparison. So the third line stays as midnightblue
or #191970
. The hue-rotate(180deg)
filter changes the text in the first two lines to #252500
.
Note: The hexadecimal rgb color #191970
is equal to hsl(240deg 63.5% 26.9%)
, while #252500
is hsl(60deg 100% 7.3%)
. The color rotation takes place in the sRGB color space, which is why the hue has been changed as expected while not maintaining the same values for saturation and lightness.