How does an object's absorption spectrum allow an astronomer to determine what kind of elements and molecules it contains?

And also, the amount of each molecule
2 answers 2