Carbon dioxide behaves like the glass windows in a car with the windows wound up in that it allows light to pass through but prevents heat from passing through. This is because carbon dioxide molecules are transparent to visible light but opaque to infrared radiation, which is the type of electromagnetic radiation that is responsible for heat transfer. When light from the sun hits the Earth's atmosphere, the carbon dioxide molecules in the atmosphere allow the light to pass through and reach the surface of the Earth. However, when the heat from the sun's rays is absorbed by the Earth's surface, the carbon dioxide molecules in the atmosphere prevent the heat from escaping back into space, trapping it in the atmosphere and contributing to the greenhouse effect. This is similar to how the glass windows in a car with the windows wound up allow light to pass through but prevent heat from passing through.