When a planet passes in front of a star, the starlight passes through the planet's atmosphere. Lines in the resulting spectrum occur where different elements absorb light at characteristic energies, indicating the composition of the planet's atmosphere.