Fog forms when air becomes saturated at the surface, meaning its temperature has fallen to its dew point (or its dew point has risen to meet its temperature). Water vapor condenses onto microscopic particles and hangs there as suspended droplets. Officially it's fog when visibility drops below 5/8 of a mile; above that, it's mist.
Radiation fog, the common one
On a clear calm night, the ground radiates heat to space and cools rapidly. Air touching it cools too, and if it reaches the dew point, fog forms, typically in valleys and low spots first, since cold air drains downhill. This is the fog that fills the pasture at dawn and burns off by mid-morning as the sun reheats the surface.
It requires clear skies, light wind, and moist air near the ground. Any real wind mixes the layer and prevents it.
Advection fog, the persistent one
Warm moist air moving over a colder surface gets chilled from below until it saturates. Unlike radiation fog, it can form and persist in wind, and it doesn't reliably burn off during the day, San Francisco's summer fog is this, and so is the fog that sits on the Gulf coast when warm air rides over cool water.
The rest
- Steam fog: cold air over much warmer water. The wisps rising from a lake on a fall morning.
- Upslope fog: air forced up a hillside cools as it rises and saturates.
- Freezing fog: droplets below freezing that flash to ice on contact with any surface. Genuinely dangerous on roads.
Watch the spread between temperature and dew point. When the gap closes to about 4°F on a clear calm evening, overnight fog becomes likely, because the temperature will keep falling toward a dew point that stays roughly put. A wide spread means it can't happen no matter how still the night is.
When it lifts
Radiation fog usually dissipates within a few hours of sunrise as surface heating raises the temperature back above the dew point, often lifting into a low stratus deck first, then breaking up. Advection fog may not lift at all until the wind direction changes. And in a valley on a short winter day, fog can persist for days when the sun never gets strong enough to break the inversion holding it in place.