Have you ever wondered why coffee leaves a stain ring only at the top level? The reason behind this is quite interesting and scientific. The following answers we picked from the internet should be able to explain it well.
The air is where it the coffee dries up and the solids inside the water from the coffee can leave the water and stick to the edge.
When you pour yourself a mug of hot coffee, you typically let it sit for 5-10 minutes until it cools down to a potable temperature. During that time, when the coffee is at its hottest, there is rapid evaporation at the surface of the liquid and coffee solids will create at the boundary between the evaporating liquid and the dry inner mug surface.
Then, when the coffee is drinkably cool, it is both at a lower temperature (= less evaporation) and you’re drinking it faster (= less accretion at any liquid depth than when you had a full cup).
Evaporation happens from the surface I.e. top of a liquid. Since coffee is hot when poured, evaporation of water from the coffee is faster. This causes the coffee level to go down ever so slightly, while the cup tries to pull the liquid surface upwards around the edges where it comes in contact, causing the coffee to dry up faster along the edges leaving a trail of dried coffee aka stain. As we drink the coffee it cools and the evaporation slows down, plus we are drinking the coffee faster than the edges get time to dry to a stain at this point. If you leave a half drunken coffee alone long enough and then sip it you will see the stain at the new level as well.
Say the coffee is 180°F when brewed. It will drop in temperature to 120°F much more rapidly than from 120°F to 80°F and a good percentage of this energy loss occurs through evaporation. So as it drops to a drinkable temperature, many insoluble solids are left caked to the vessel.