When water condenses on a piece of glass, the glass fogs up. You may not mind this on the windows in your home, but in your car, a foggy windshield is both annoying and unsafe. When warm air touches one side of the window and cool air touches the other, the result is fog. The dryer the air, the less the condensation. When it's cold outside, it's also dry; hence, no fog on the windows--until you turn on the heater or start breathing inside your car. Now you have added both warmth and moisture (humidity) and the windows begin to fog up. Or maybe it's hot and humid outside and you run the dry air conditioner inside: fog. You can avoid these scenarios by knowing a few tricks.
Check for sources of moisture inside the car. Look for wet floor mats, snow on passengers' shoes, perspiration and breathing.
Eliminate the moisture by cracking a window slightly or setting the vents on "fresh" versus "recirculate" so that moisture is taken outside the car instead of blown around inside. If the moisture is severe, turn the fan on high and open a window slightly
Warm the windows. If the air outside is cold and wet--such as during a rainstorm--warming the windows slightly will reduce fog because they won't be as affected by the humid weather. Turn heater vents so they blow directly on the windows.
Run your windshield wipers if the fog is on the outside of the windshield. If the air-conditioning is running inside the car and the outside temperature is warm and humid, water will condense on the outside of your windows.
Turn on both the air-conditioning and the heater. Warm air will circulate, but the air conditioner will keep the air dry, reducing condensation and fog.
Have your air conditioner serviced if none of these suggestions work. If the AC is not functioning correctly, it is not removing moisture from the air. Keep a microfiber cloth handy for wiping the fog quickly from the inside of your windshield so you are not driving in unsafe conditions.