We get so many questions about why scuba masks fog and what works best in stopping the fogging that I figured it may help if I cut & paste my primary school dissertation paper here. Teachers can feel free to make corrections. I only got a C+ the first time around anyway. Others can add on.
Why do masks fog?
Masks fog because you have warm moist air enclosed in a space that has relatively cold glass as one of the sides. One time when you visit a cold country in winter, get close to a window inside a house and blow gently on it. Guaranteed fog up. When the warm moist air touches the colder glass, the temperature is reduced at that spot and the air can no longer hold as much moisture. Cold air does not hold as much moisture as warm air so it drops off the excess moisture onto the glass inside your mask. The glass surface is almost the perfect surface for the water molecules to form and combine just enough to make the drops big and plentiful enough to look like fog / condensation.
What is fog?
The fogging on your mask is the moisture from the air forming small droplets on the glass. The droplets may be tiny but they are also shaped like semi-spherical drops packed closely together. The bumpy surface makes it near impossible to focus through although light does pass through the droplets. The light just gets twisted around in every different direction by the bumpy surface.
So how can you stop the fogging?
You have a couple of options here. 1) take the moisture out of the air in your mask. Well that's not so easy or good since you will need to be totally dehydrated for that to happen. 2) take the heat out of the air in your mask. Ewww, another bad option since the lack of body heat likely means you are deceased. 3) make sure the water on the other side of the glass is not so cold. Strike three we don't usually like diving in 37 degree Celsius water. Having said that, not exhaling through your nose with help lower the first two problems but you still have to do more.
The best option to stop the fogging is to make it harder for the water droplets to form on the glass in the first place. If instead of droplets on the glass, you could get a thin film of water, you would be better able to see and focus through it. You can do this by covering the inside of the glass with a surfactant. What the hell is that?!?! A surfactant is a solution that reduces the surface tension of water. Basically, when a surfactant is on the glass, those semi-spherical droplets of water that make up the condensation will quickly flatten out, combine and form a thin flat layer of moisture.
That's the good news but where do you get surfactant? Soap, laundry detergent, shampoo, etc. all contain the compound and are normally used to separate out dirt and oil from whatever they are cleaning. Commercial products for diving like Sea Gold also have it. Your lungs are full of a biological form of it to keep your lung passages open. Some of that gets into your spit but the amount varies from person to person. That's why spit works for some people and not others or it works better at different times for the same person. If you have a cold and you manage to dig deep down for a real guttural spit, you will be sure to get plenty of surfactant!
What about a new mask? They usually have a silicone film on the surface to help keep them looking pretty until you buy them. The film is also said to help protect against mildew. Unfortunately, the same properties that help it to look good also inhibit the ability of the surfactant to work properly. That's why you have to remove the film by scrubbing with a toohpaste (not gel) for 10-15 minutes. If you then use some sort of surfactant before each dive, you should be able to avoid fogging.
Clear as mud now, right?