How do you invert a color?
Subtract each RGB channel from 255. For example, rgb(51, 102, 204) becomes rgb(204, 153, 51). In HEX you subtract each pair from FF, so #3366CC becomes #CC9933.
Is an inverted color the same as a complementary color?
Not usually. Both point to the opposite hue on the color wheel, but inversion also flips lightness, while a complementary color normally keeps the original lightness. Light pink (#FFC0CB) inverts to a very dark teal (#003F34), whereas its complement is a light mint tone. They only match when the original color sits at 50% lightness.
How do I invert colors with CSS?
Use the filter property with invert(100%) or invert(1) to invert everything an element renders, including images and text. Lower values such as invert(50%) give partial results. To change only one color value, calculate the inverted HEX code and set it directly instead.
Does inverting a color always create good contrast?
No. Very light and very dark colors invert into strong contrasts, but mid-tones stay in the middle. A medium gray like #808080 inverts to #7F7F7F, which is almost the same color. Check any inverted pair with a contrast checker before using it for text.