Google wrote
Energy coming from the sun arrives in the form of radiant energy. The sun emits a wide spectrum of frequencies, but considering visible light is enough for our purposes here. Glass has the property of allowing most low-frequency sunlight to pass through.
When this sunlight reaches the surfaces inside the home, they either absorb it or reflect it. Absorbing the light energy converts it to radiant heat. Glass is less transparent to this heat than visible light, so the heat is trapped inside the house.
This trapping of heat is called the greenhouse effect.