The greenhouse effect results from the feature certain gases have of absorbing infra-red radiation, owing to the natural frequencies of their electrons. The most common constituents of air, which are nitrogen and oxygen, don't have that feature. But water vapor, carbon dioxide, methane, nitrous oxide, and some artificial gases do.

Visible light and radio waves are able to pass through the atmosphere and strike the surface of Earth with little hindrance, because gases don't absorb much of them. The other radiation from the sun is largely absorbed in the atmosphere, which it warms.

In the absence of greenhouse gases, Earth's surface would radiate heat in the form of infra-red radiation to outer space, which has a radiative temperature of -460 deg F. But greenhouse gases intercept and absorb some of the infra-red radiation and warm the atmosphere. Earth has to radiate through an atmosphere that is hazy in the infra-red range and warm, so Earth's surface stays slightly warmer. The atmosphere also radiates to space but, on balance, both the surface and the atmosphere stay warmer than they would be if there were no greenhouse gases. For more technical information, try Google: greenhouse gases