Recall that a blackbody of a given temperature has a particular shape. Therefore, by measuring the shape of a blackbody spectrum one can derive the temperature of the object.
So, by taking a spectrum of a star we can measure both how hot the star is and
what its chemical composition is.