Global warming is caused by greenhouse gases like carbon dioxide and methane trapping heat in the atmosphere, increasing the Earth's temperature. This occurs through the greenhouse effect, where gases act like the glass of a greenhouse or bottle, trapping heat close to the Earth's surface and causing the planet to warm up over time. If the Earth were like a bottle with trapped heat, it would become very hot without the greenhouse gases escaping into space.