If you've ever been in a greenhouse, you know it's warm inside even on a cold winter day. The sun's light rays come through the glass and turn into heat rays. Because heat rays are shaped differently than light rays, they can't get back out through the glass as easily, so most of the heat stays trapped inside the greenhouse. The same thing happens in a parked car on a sunny day. Our planet is heated in much the same way.
Sunlight passes through the earth's transparent atmosphere to heat the planet below.
Some of that heat and light is radiated back from the earth's surface and absorbed by water vapor and various trace gases, such as carbon dioxide, ozone, methane, and nitrous oxide. These heat-trapping gases, known as greenhouse gases, cause the planet to heat up. The greenhouse effect refers to the phenomenon by which gases in the earth's atmosphere allow the sun's energy primarily in wavelengths which form visible light to reach the earth and heat up the oceans and land. But when the earth radiates the heat back at longer wavelengths, these same gases trap some of that heat in the atmosphere. The physical processes trapping the energy however, are very different in the two systems.