Clouds form when sunlight and heat from the sun warm the air, causing it to rise and cool, condensing into water droplets or ice crystals. There are three main types: convection, or rising air near the Earth"s surface; advection along coastal slopes; and the meeting of cold and warm air masses. Although clouds and fog are similar, they differ in their ability to produce rain, snow, lightning, and fog only affects visibility.