Most of the infrared waves radiated by the earth, however, cannot travel back into space. Infrared radiation is absorbed by water vapor and carbon dioxide in the lower atmosphere. These gases trap the heat, keeping it near the earth's surface. In this way, the atmosphere acts as a blanket, keeping the earth's heat from escaping into space. The trapping of heat by carbon dioxide and water vapor in the atmosphere is called the greenhouse effect.
Clouds also have an effect in keeping the earth's surface warm.
Clouds increase the greenhouse effect by absorbing some of the infrared radiation that would normally be lost into space. The clouds radiate some of the heat back to the surface. Water vapor in clouds absorbs infrared radiation and radiates the heat back to the earth's surface. Air also cools as heat radiates from it into space. For example, air cools more quickly on clear nights than on cloudy nights.