Four inks and a black plate
Printing takes light away. Paper reflects light, and each layer of ink absorbs some of it. Cyan, magenta and yellow are the three colored inks, and K is black, which printers call the key plate. A screen does the opposite and adds light.
Why add black, if the other three together should make black? Full cyan, magenta and yellow give a dark but imperfect black. Black ink gives sharper text and outlines, costs less than layering three colors and uses less ink, so the page dries faster. CMYK values are written as four percentages, like cmyk(0%, 54%, 91%, 2%).
How a screen color becomes CMYK
The Color Picker uses the simple formula. It takes the black first: K is how far the brightest RGB channel falls short of full. Then each ink is what's left of its own channel once the black is taken out.
Take the orange #F97316, which is rgb(249, 115, 22). Red is the brightest channel at 249 of 255, so K is 2% and cyan is 0%. Green at 115 gives 54% magenta, and blue at 22 gives 91% yellow. The result is cmyk(0%, 54%, 91%, 2%).
Pure black puts everything into K, cmyk(0%, 0%, 0%, 100%). Pure blue, #0000FF, needs no black at all: cmyk(100%, 100%, 0%, 0%). The conversion doesn't round trip either. #7C3AED is cmyk(48%, 76%, 0%, 7%), and turning those percentages back into RGB gives #7B39ED.
Why print won't match the screen
No single formula turns RGB into CMYK. Both are tied to a device, so the result depends on the inks, the paper and the press. Print shops use ICC color profiles to map one to the other. The simple formula above ignores all of that, so treat its numbers as a starting point, not a promise of how a job will print.
Gamut is the other gap. Screens and inks each reach their own range of colors, and a color you see on one may not be reproducible on the other. Ask the printer for a proof when the color matters.
CSS Color Level 4 doesn't define a CMYK function, so on the web you write the color as hex, rgb(), hsl() or oklch() and do the CMYK conversion at the end, for print.