
In 2001, astronomers using the Hubble telescope first captured the atmospheric imprint of planet HD 209458 b, seeing traces of sodium in its spectrum.
Imagine looking at a lightbulb through colored glass: the glass absorbs some light, and you see what color it is. It's similar with a planet's atmosphere: we compare the star's light during the planet's passage and without it, and the difference shows what the gases "drank".